Skip to content

Conversation

@Reversean
Copy link
Member

Closes #137

Some playground UI preview:

recording_2025-12-12_02.22.45.mp4

@Reversean Reversean changed the title feat(svelte-integration): add error handling research and test playgr… Test Svelte playground Dec 12, 2025
@Reversean Reversean force-pushed the feature/svelte-integration-playground branch 2 times, most recently from 9501e2e to 89f424e Compare December 17, 2025 20:19
@Reversean Reversean marked this pull request as ready for review December 17, 2025 20:38
@neSpecc neSpecc requested a review from Copilot December 18, 2025 20:40
Copy link

Copilot AI left a 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.

Comment on lines +34 to +36
triggerError = false;
reset();
}}
Copy link

Copilot AI Dec 18, 2025

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).

Suggested change
triggerError = false;
reset();
}}
triggerError = false;
reset();
}}

Copilot uses AI. Check for mistakes.
<div class="container">
<header>
<h1>🧪 SvelteKit Error Handling Test Suite</h1>
<a href="/packages/svelte/playground/static">← Back to Home</a>
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
<a href="/packages/svelte/playground/static">← Back to Home</a>
<a href="/">← Back to Home</a>

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +15
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
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +20
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
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,394 @@
/* Hawk.so Example Styles */
@import url('https://fonts.googleapis.com/css?family=Roboto:400,500,700&display=swap');
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
@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');

Copilot uses AI. Check for mistakes.

<div class="error-boundary-container">
<svelte:boundary onerror={handleError}>
<ErrorEffectComponent {triggerError}/>
Copy link

Copilot AI Dec 18, 2025

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.

Copilot uses AI. Check for mistakes.

# Environment
.env
.env.example
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
.env.example

Copilot uses AI. Check for mistakes.
</svelte:head>

<nav>
<a href="/packages/svelte/playground/static">Home</a>
Copy link

Copilot AI Dec 18, 2025

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.

Suggested change
<a href="/packages/svelte/playground/static">Home</a>
<a href="/">Home</a>

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +9
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
Copy link
Member

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

Comment on lines +6 to +9
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
Copy link
Member

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

Comment on lines +14 to +17
### Prerequisites

- Node.js 18+
- Yarn 1.x
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Svelte playground project

3 participants