You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Errors not properly reported when streaming data fails in Sveltekit on Cloudflare #17009
I've followed the documented instructions for setting up Sveltekit and Sentry on Cloudflare. I've created a page in the app that streams data to the client. The streamed data is set up to always fail:
exportconstload: PageServerLoad=async()=>{conststreamedData=newPromise((resolve,reject)=>setTimeout(()=>reject(newError('Slow data error')),2000))return{ streamedData }}
On the client, I have a page that awaits the data but doesn't catch failures:
When run locally an issue is reported from the server with details of the error:
Actual Result
When run in Cloudflare there is no server-side error, just this <unknown> error from the client:
I think the server error should have been reported as that would be consistent with the behavior I see locally. If I were to catch the rejected promise on the client, then the unhandled error won't be captured by Sentry at all. I don't love the <unknown> error on the client but I think that's outside the scope of this issue. I think the bigger problem here is the lack of capture on the server.
So I took a look at this and I think the problem seems to be that the error thrown after the timeout happens after our sentryHandle and sentryHandleInitCloudflare already finished (since they close after the load function returns the promise and the rest of the page is ready to be sent to the client).
Then, this error is thrown. It gets caught by SvelteKit and kit also sends it into the handleError hook, where our SDK actually picks it up and sends it off.
However, at this point, it looks like the CF worker function doesn't wait anymore until the request is sent. I need to check if we can somehow access Cloudflare's waitUntil utility that we use to flush within the handler.
I opened #17044 which at least locally for me worked and the server error from your repro was sent successfully to Sentry. Should go out in the next few days.
Activity
Lms24 commentedon Jul 15, 2025
Hey @RaniSputnik thanks for reporting and for providing a reproduction (once again, much appreciated!). I'll take a look today.
Lms24 commentedon Jul 16, 2025
So I took a look at this and I think the problem seems to be that the error thrown after the timeout happens after our
sentryHandleandsentryHandleInitCloudflarealready finished (since they close after theloadfunction returns the promise and the rest of the page is ready to be sent to the client).Then, this error is thrown. It gets caught by SvelteKit and kit also sends it into the
handleErrorhook, where our SDK actually picks it up and sends it off.However, at this point, it looks like the CF worker function doesn't wait anymore until the request is sent. I need to check if we can somehow access Cloudflare's
waitUntilutility that we use to flush within the handler.Lms24 commentedon Jul 16, 2025
I opened #17044 which at least locally for me worked and the server error from your repro was sent successfully to Sentry. Should go out in the next few days.
github-actions commentedon Jul 17, 2025
A PR closing this issue has just been released 🚀
This issue was referenced by PR #17044, which was included in the 9.40.0 release.