Skip to content

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

Closed

Description

@RaniSputnik

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

9.38.0

Framework Version

Sveltekit 2.17.1

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/RaniSputnik/sentry-issues/tree/streamed-data-error

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:

export const load: PageServerLoad = async () => {
    const streamedData = new Promise((resolve, reject) => 
        setTimeout(() => reject(new Error('Slow data error')), 2000))
    return { streamedData }
}

On the client, I have a page that awaits the data but doesn't catch failures:

{#await data.streamedData}
	<p>Loading...</p>
{:then streamedData}
	<p>Finished loading successfully: {JSON.stringify(streamedData)}</p>
{/await}

Steps to Reproduce

  1. Clone the linked reproduction above
  2. Deploy to Cloudflare workers
  3. Visit the /streaming-error page

Expected Result

When run locally an issue is reported from the server with details of the error:

Image

Actual Result

When run in Cloudflare there is no server-side error, just this <unknown> error from the client:

Image

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.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jul 15, 2025
  2. Lms24 commented on Jul 15, 2025

    @Lms24
    Member

    Hey @RaniSputnik thanks for reporting and for providing a reproduction (once again, much appreciated!). I'll take a look today.

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jul 15, 2025
  4. self-assigned this
    on Jul 16, 2025
  5. Lms24 commented on Jul 16, 2025

    @Lms24
    Member

    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.

  6. Lms24 commented on Jul 16, 2025

    @Lms24
    Member

    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.

  7. github-actions commented on Jul 17, 2025

    @github-actions
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions