-
Notifications
You must be signed in to change notification settings - Fork 4
Test Svelte playground #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9501e2e to
89f424e
Compare
…awk Catcher implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a comprehensive SvelteKit playground for testing and demonstrating the Hawk.so error tracking integration with Svelte 5. The playground provides 14 different error scenarios to validate error handling across various contexts including load functions, lifecycle hooks, event handlers, async operations, form actions, error boundaries, and store subscriptions.
Key Changes
- Complete SvelteKit application setup with Vite, TypeScript, and Svelte 5 configuration
- Implementation of both client-side and server-side error handlers with console logging
- 14 test pages demonstrating different error scenarios and their expected behavior
- Global error handler setup with visual console markers (🔴, 🟡, 🟢) to distinguish error capture locations
Reviewed changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Project setup with SvelteKit dependencies and Hawk.so integration |
| vite.config.ts | Vite configuration with SvelteKit plugin and network host access |
| svelte.config.js | SvelteKit configuration with auto adapter and vite preprocessing |
| tsconfig.json | TypeScript configuration with strict mode and Svelte-specific settings |
| hooks.client.ts | Client-side error handler with Hawk initialization and logging |
| hooks.server.ts | Server-side error handler with detailed error logging |
| app.css | Complete styling system with dark theme and component styles |
| +layout.svelte | Root layout with global error handler registration |
| +page.svelte | Home page with playground introduction and navigation |
| errors/+page.svelte | Error test suite index with categorized test scenarios |
| Error test pages | Individual test pages for various error scenarios (load, lifecycle, events, async, forms, boundaries, stores) |
| errorStore.ts | Store with intentional subscription error for testing |
| yarn.lock | Locked dependencies for reproducible builds |
| README.md | Comprehensive documentation of error scenarios and testing guide |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| triggerError = false; | ||
| reset(); | ||
| }} |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected. Lines 34-36 use tabs while the rest of the file uses spaces. This should be normalized to match the file's indentation style (2 spaces).
| triggerError = false; | |
| reset(); | |
| }} | |
| triggerError = false; | |
| reset(); | |
| }} |
| <div class="container"> | ||
| <header> | ||
| <h1>🧪 SvelteKit Error Handling Test Suite</h1> | ||
| <a href="/packages/svelte/playground/static">← Back to Home</a> |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL path references a static file path incorrectly. The href should be "/" for the home page, not "/packages/svelte/playground/static". This appears to be a repository structure path rather than a web application route.
| <a href="/packages/svelte/playground/static">← Back to Home</a> | |
| <a href="/">← Back to Home</a> |
| console.error('🔴 [Server handleError] Caught error:', { | ||
| error, | ||
| status, | ||
| message, | ||
| route: event.route.id, | ||
| url: event.url.pathname | ||
| }); | ||
|
|
||
| return { | ||
| message: message || 'An unexpected server error occurred', | ||
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | ||
| route: event.route.id |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event.route.id property can be null and needs null-safe handling. The route.id is null for error pages and certain dynamic routes, which could cause the returned object to have inconsistent types.
| console.error('🔴 [Server handleError] Caught error:', { | |
| error, | |
| status, | |
| message, | |
| route: event.route.id, | |
| url: event.url.pathname | |
| }); | |
| return { | |
| message: message || 'An unexpected server error occurred', | |
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | |
| route: event.route.id | |
| const routeId = event.route.id ?? 'UNKNOWN_ROUTE'; | |
| console.error('🔴 [Server handleError] Caught error:', { | |
| error, | |
| status, | |
| message, | |
| route: routeId, | |
| url: event.url.pathname | |
| }); | |
| return { | |
| message: message || 'An unexpected server error occurred', | |
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | |
| route: routeId |
| console.error('🔴 [Client handleError] Caught error:', { | ||
| error, | ||
| status, | ||
| message, | ||
| route: event.route.id, | ||
| url: event.url.pathname | ||
| }); | ||
|
|
||
| return { | ||
| message: message || 'An unexpected client error occurred', | ||
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | ||
| route: event.route.id |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event.route.id property can be null and needs null-safe handling. The route.id is null for error pages and certain dynamic routes, which could cause the returned object to have inconsistent types.
| console.error('🔴 [Client handleError] Caught error:', { | |
| error, | |
| status, | |
| message, | |
| route: event.route.id, | |
| url: event.url.pathname | |
| }); | |
| return { | |
| message: message || 'An unexpected client error occurred', | |
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | |
| route: event.route.id | |
| const routeId = event.route.id ?? 'UNKNOWN_ROUTE'; | |
| console.error('🔴 [Client handleError] Caught error:', { | |
| error, | |
| status, | |
| message, | |
| route: routeId, | |
| url: event.url.pathname | |
| }); | |
| return { | |
| message: message || 'An unexpected client error occurred', | |
| code: (error as any)?.code ?? 'UNKNOWN_ERROR', | |
| route: routeId |
| @@ -0,0 +1,394 @@ | |||
| /* Hawk.so Example Styles */ | |||
| @import url('https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap'); | |||
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Google Fonts URL uses an older syntax. Consider updating to the more modern CSS2 API with explicit weight syntax for better control and performance. The current URL works but css2 API is recommended.
| @import url('https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap'); | |
| @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap'); |
|
|
||
| <div class="error-boundary-container"> | ||
| <svelte:boundary onerror={handleError}> | ||
| <ErrorEffectComponent {triggerError}/> |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import statement for the ErrorEffectComponent. The component is used on line 27 but not imported at the top of the script section.
|
|
||
| # Environment | ||
| .env | ||
| .env.example |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gitignore file has a logical error. Line 22 adds .env.example to be ignored, but line 23 immediately negates it with !.env.example. Since .env.example should be committed (it's a template file), only the negation is needed, or these two lines should be removed entirely as .env on line 21 already handles the actual environment file.
| .env.example |
| </svelte:head> | ||
|
|
||
| <nav> | ||
| <a href="/packages/svelte/playground/static">Home</a> |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL path references a static file path incorrectly. The href should be "/" for the home page, not "/packages/svelte/playground/static". This appears to be a repository structure path rather than a web application route.
| <a href="/packages/svelte/playground/static">Home</a> | |
| <a href="/">Home</a> |
| preprocess: vitePreprocess(), | ||
| kit: { | ||
| adapter: adapter() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 2-space indentation. You can copy the .editorconfig file from some of our repos
| preprocess: vitePreprocess(), | ||
| kit: { | ||
| adapter: adapter() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add JSdocs here with explanation
| ### Prerequisites | ||
|
|
||
| - Node.js 18+ | ||
| - Yarn 1.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is redundant info, I guess
Closes #137
Some playground UI preview:
recording_2025-12-12_02.22.45.mp4