Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Jul 16, 2025

In SvelteKit, users can return a Promise from a load function which causes a streamed http respnse to be sent. If the promise rejects after it is returned and the initial response is sent, an error is thrown server-side. This error will not be captured by our request handler wrappers because at this time, they already finished.

However, the error will be caught via our handleErrorWithSentry hook. This means we actually still catch the error but because the cloudflare function already terminated directly after the rejection, it is not sent successfully (i.e. the good old flush problem).

This PR makes sure we use of Cloudflare's waitUntil function which fortunately is available within the error handler hook.

closes #17009

cursor[bot]

This comment was marked as outdated.

@Lms24 Lms24 self-assigned this Jul 16, 2025
@Lms24 Lms24 requested review from a team, AbhiPrasad and chargome and removed request for a team July 16, 2025 16:32
@Lms24 Lms24 changed the title fix(sveltekit): Ensure errors from streamed responses are sent fix(sveltekit): Ensure server errors from streamed responses are sent Jul 16, 2025
Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

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.

Errors not properly reported when streaming data fails in Sveltekit on Cloudflare

4 participants