-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
Which project does this relate to?
Start
Describe the bug
Errors thrown on server side does not serialize correctly. Here's an example:
class TestError extends Error {
constructor(message: string = 'Test error') {
super(message)
this.name = 'TestError' // ← Error name set to 'TestError'
}
}
export const testError = createServerFn().handler(async () => {
throw new TestError('This is a test')
})and on the client side:
const testErrorMutation = useServerFn(testError);
// ...
<Button
onClick={async () => {
try {
await testErrorMutation()
} catch (err) {
const error = err as Error
console.log(error.name) // prints 'Error' instead of 'TestError'
}
}}
>
Throw server error
</Button>While the error thrown has the name 'TestError', this information gets lost in serialization/deserialization.
Your Example Website or App
https://stackblitz.com/edit/github-egpnw7wu-6dmvze6t?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
N/A
Expected behavior
It should print 'TestError'
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.132.0
- OS: macOS
- Browser: Chrome
- Browser Version: 141.0.7390.122
- Bundler: Vite
- Bundler Version: 7.1.7
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels