Skip to content

breaking: render the root error page for handle and endpoint errors when the request expects HTML#16488

Closed
Nic-Polumeyv wants to merge 6 commits into
sveltejs:version-3from
Nic-Polumeyv:render-error-page-handle-endpoint
Closed

breaking: render the root error page for handle and endpoint errors when the request expects HTML#16488
Nic-Polumeyv wants to merge 6 commits into
sveltejs:version-3from
Nic-Polumeyv:render-error-page-handle-endpoint

Conversation

@Nic-Polumeyv

Copy link
Copy Markdown
Contributor

Fixes #13646

Fatal errors from handle and +server.js now go through respond_with_error, which renders the root +error.svelte, when the request is a top-level document request that accepts HTML. Data, route-resolution, remote, sub-request, prerender and subresource requests keep the previous behavior, reusing the Sec-Fetch-Dest set from #16463.

This was already safe for handle errors: if the root layout load fails because the hook died before setting up locals, respond_with_error's existing catch falls back to error.html.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 23, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 6db644f:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/6db644f7a8e593924ea44b9f1c4b53b1ec9509d2

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16488

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6db644f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Major

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

@theetrain

Copy link
Copy Markdown
Contributor

Thanks for handling this. A couple of thoughts:

  • This may need to be marked as a breaking change since previous behaviour no longer matches this new behaviour.
  • Does only the root +error.svelte get rendered when a deep-nested route throws, or will the nearest +error.svelte render?

@Nic-Polumeyv Nic-Polumeyv changed the title feat: render the root error page for handle and endpoint errors when the request expects HTML breaking: render the root error page for handle and endpoint errors when the request expects HTML Jul 23, 2026
@Nic-Polumeyv

Nic-Polumeyv commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Root only, same as 404s. The nearest boundary would need the route's load chain, which already failed for handle and does not exist for +server.js.

@Nic-Polumeyv

Nic-Polumeyv commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

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.

Render +error.svelte whenever possible

2 participants