Repository navigation
fix: render the nearest +error.svelte at the depth it occupies when an error is thrown during rendering - #16526
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/ad36cd7466e9d515fe4b883a7f9c4272f86e79b3Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: ad36cd7 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 |
commented
Jul 28, 2026
|
On version-3 the server and client don't just place render errors differently, they render different |
c735389 to
9e20ac2
Compare
4b2e4a6 to
c9cbc9d
Compare
17d3064 to
0fa881f
Compare
b1380cc to
459d4f4
Compare
…n error is thrown during rendering
the client and the server had the same walk, so a change to one silently diverged from the other
459d4f4 to
ad3c9f6
Compare
Fixes the error page placement half of #16345.
Since #16301, an error thrown while rendering is caught by the boundary at the depth that threw it, so the nearest
+error.svelterenders inside every layout between its own directory and the throwing component. The same error thrown inloadrenders that component at its own depth with the intervening layouts unmounted. Before #16301 the generated root only armed a boundary at depths that own an error component (failed={errors[depth] ? failed : undefined}), which made render errors rethrow up to the owning depth. The unconditional boundary plus the nearest-ancestorfindLastchanged that without a changeset, first shipping in 3.0.0-next.8, the version #16345 was filed against. SvelteKit 2 places the same error at the owning depth.The client and the server now build that array with one shared function instead of a copy each. Nearest-boundary selection (#14410, #15745) is unchanged, only where the selected error page renders.
set_nearest_error_pagerebuilt the chain with no errors at all, so a render error inside a form error page fell back to the root one. It now passes the route's.Conditional arming exposed a latent ordering problem in the #16296 reset path:
navigatedrains the resetters as soon as the new props are applied, before the flush, so a stale failed boundary re-renders its old content (which throws again) at a depth the new tree may no longer have. Unconditionally armed boundaries silently re-swallowed that throw on every teardown; with sparse arming it escaped to an ancestor boundary and rendered an error page instead of the new route. The drain now runs aftersettled(), matching the fork branch, which resets after state is applied. Boundaries at removed depths are simply unmounted by the flush; boundaries at surviving depths reset against a consistent tree.The async test app's
/server-error-boundaryroute already had exactly this shape, with the root error page silently rendering inside the section layout. The two existing tests now assert the layout is gone.