feat: allow error boundaries to work on the server#17672
Conversation
This makes error boundaries run on the server if a new `onerror` handler is passed to `render`. `onerror` can either synchronously or asynchronously return a value. It should be a sanitized JSON.stringify-able value so that it can be passed to the client for hydration via a comment. `mount/hydrate` also get the `onerror` property. If no `onerror` is passed to `render` it will just throw just like before, hence this is backwards compatible. This work is important for SvelteKit to allow `+error.svelte` to make use of them and in general to make boundaries properly work during SSR (also see sveltejs/kit#14398). closes #15370
🦋 Changeset detectedLatest commit: 584d271 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
I wonder if we should call the app-level |
|
Marking as draft, want to see if this really does what it should in combination with SvelteKit |
|
If a |
|
this was too cumbersome to do with the suggestion UI: #17673 |
Rich-Harris
left a comment
There was a problem hiding this comment.
with the caveat that we should try this out in SvelteKit to make sure we haven't missed anything obvious, this looks excellent
|
Recapping offline discussion: it would be much better if |
|
Counterpoint: sveltejs/kit#7756 |
Take advantage of sveltejs/svelte#17672 to add the `handleError` hook as `transformError` so that error boundaries run on the server. Behind an experimental flag. Closes #14808 Closes #14410 Closes #14398
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## svelte@5.53.0 ### Minor Changes - feat: allow comments in tags ([#17671](#17671)) - feat: allow error boundaries to work on the server ([#17672](#17672)) ### Patch Changes - fix: use TrustedHTML to test for customizable <select> support, where necessary ([#17743](#17743)) - fix: ensure head effects are kept in the effect tree ([#17746](#17746)) - chore: deactivate current_batch by default in unset_context ([#17738](#17738)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This makes error boundaries run on the server if a new
onerrorhandler is passed torender.onerrorcan either synchronously or asynchronously return a value. It should be a sanitized JSON.stringify-able value so that it can be passed to the client for hydration via a comment.mount/hydratealso get theonerrorproperty.If no
onerroris passed torenderit will just throw just like before, hence this is backwards compatible.This work is important for SvelteKit to allow
+error.svelteto make use of them and in general to make boundaries properly work during SSR (also see sveltejs/kit#14398).closes #15370
Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.packages/svelte/src, add a changeset (npx changeset).Tests and linting
pnpm testand lint the project withpnpm lint