-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sentry.sentryHandle()
raises TypeError: Body is unusable: Body has already been read
when node >= 20 (20.x, 22.x)
#14583
Comments
export const handle = sequence(mySelfHandle, mySelfHandle);
export const handle = sequence(mySelfHandle);
|
Hello, can you provide a small runnable reproduction example? This can be for example a GitHub repository with a small SvelteKit project that includes e.g. a button for the request and the Sentry setup. Thank you! :) |
https://github.com/chenqianhe/node-20-sentry-demo https://node-20-sentry-demo.vercel.app/ I have to say, at the moment I can't reproduce this bug in either this minimal example or our real project. |
Hey @chenqianhe just chiming in here with some extra context. I can't think of a specific reason why you'd get this error. Do we know if this happens on the request or the response? If request: The only thing we do is that we clone the original request to extract request data which later on would get attached to error events (for errors during this request cycle). I used If response: The only way we'd potentially change a respnse body is by injecting some Html into the rendered page. However, we use SvelteKit's official Let us know once you can reproduce this and if you by chance find out more! |
According to the Sentry error, this happens on the request. I find it very strange too - Sentry shouldn't cause this kind of issue. I've also checked the corresponding source code, which shows that it operates after cloning, and there's no body reading involved. I'm now suspecting whether it might be errors caused by other reasons that eventually surfaced at this point, leading to a misdiagnosis/false identification. |
From MDN:
So I do think we're using |
Hey. I'm having the same issue.
I'm using: I also have: export const handle = sequence(Sentry.sentryHandle(), secondaryHandle); I can POST 5 times and it doesn't happen, but on the 6th it will, and then the 7th it's fine. Not to that exact cadence, but the point is it's sporadic, with no change to the request body. One thing to note is that while it is happening in my dev VM (5.10.0-33-cloud-amd64) on both vite dev and vite build, it is not happening when the exact code is deployed to our staging/production env on Azure App Services. Both are running Node 20 LTS. |
Thanks! I reached out to Vercel internally if they have an idea what might be going on. |
Quick update: If anyone can provide a reliable minimal reproduction, we're happy to take a look (also the svelte maintainers). For now, this unfortunately is too unspecific to debug. Thanks! |
I have been getting this issue as well. I upgraded from 8.34.0 to 8.40.0 and have been getting bombarded with this error. I have endpoints which perform My hooks.server.ts have not changed I use the sequence method:
|
Hmm this is interesting, thanks @Pascaltib ! @chenqianhe or @Shuuru can you confirm that this behaviour only started appearing in recent SDK versions? Or more specifically that it doesn't appear in version 8.34.0? Just to be clear: I still don't have a reproduction for this. If you can, please provide one! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/sveltekit
SDK Version
8.42.0
Framework Version
"@sveltejs/kit": "^2.6.2", "svelte": "^4.1.2", "@sveltejs/adapter-vercel": "^5.5.0"
Link to Sentry event
https://learnie-ai.sentry.io/issues/6106002320/events/32c06c33715a481caeabbb2569eb7853/?project=4505632768262144
Reproduction Example/SDK Setup
On
hooks.server.ts
:Steps to Reproduce
Expected Result
All requests are received and returned normally
Actual Result
A small number (one or two) of them return results normally, but the rest all have errors:
The text was updated successfully, but these errors were encountered: