Skip to content

Conversation

@georgecrawford
Copy link
Contributor

@georgecrawford georgecrawford commented Feb 12, 2022

Fixes #3807

I'm honestly not sure this is the right place, or the right treatment for errors thrown in shadow endpoints, but it seems wrong that they weren't being passed to the handleError hook. I added a failing test, and tracked down a possible fix location. The test still fails as the assertion for page.textContent('#message') is getting the error message, but expecting an empty string. I don't know what's desired here (I just copied the 'error in endpoint' test above), so the failure might indicate the fix is more complex than I thought. Anyway, it's a start!

Please don't delete this checklist! 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

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

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Feb 12, 2022

🦋 Changeset detected

Latest commit: 8411533

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 Patch

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

@netlify
Copy link

netlify bot commented Feb 12, 2022

✔️ Deploy Preview for kit-demo canceled.

🔨 Explore the source changes: 0b87fc5

🔍 Inspect the deploy log: https://app.netlify.com/sites/kit-demo/deploys/6208270ac6c4b90007e0e0a5

@Rich-Harris
Copy link
Member

Thanks. handleError is only called for unexpected errors — returning { status: 500 } shouldn't result in handleError running. This distinction wasn't covered by the existing tests, so I added some and added the handle_error call where it needs to go: 8411533

@georgecrawford
Copy link
Contributor Author

Thanks @Rich-Harris. I was pretty sure I was close but not quite right on this one!

@Rich-Harris Rich-Harris merged commit 2b69e4d into sveltejs:master Feb 14, 2022
@georgecrawford georgecrawford deleted the shadow-endpoint-handle-error branch February 14, 2022 21:13
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.

Shadow Endpoint errors don't hit handleError in SSR

2 participants