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
Sentry.sentryHandle() raises TypeError: Body is unusable: Body has already been read when node >= 20 (20.x, 22.x) #14583
Use node 20.x or node 22.x (btw, no bugs on Node 18.x)
Enable Sentry
Send multiple requests to an interface at the same time
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:
TypeError: Body is unusable: Body has already been read
at consumeBody (node:internal/deps/undici/undici:5463:15)
at _Request.json (node:internal/deps/undici/undici:5416:18)
at POST (file:///var/task/vercel/path0/.svelte-kit/output/server/entries/endpoints/api/v1/quiz/freeform/_server.ts.js:20:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async render_endpoint (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:184:20)
at async resolve2 (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:2721:22)
at async sessionCookieInvalidationHandle (file:///var/task/vercel/path0/.svelte-kit/output/server/chunks/hooks.server.js:68:20)
at async /var/task/vercel/path0/node_modules/@sentry/sveltekit/build/cjs/server/handle.js:140:21
at async instrumentHandle (/var/task/vercel/path0/node_modules/@sentry/sveltekit/build/cjs/server/handle.js:128:27)
at async respond (file:///var/task/vercel/path0/.svelte-kit/output/server/index.js:2615:22)
Reacted by Pascal Tiberghien, Gabriel Sperrer, Qianhe Chen, William Overton, James Birtles and Boris Lemke
I'm sure it's a Sentry related error because everything works fine after I removed it:
exportconsthandle=sequence(mySelfHandle);
I don't think it's an error caused by undici, because I checked the source code and found that the clone function in fetch provided by undici is indeed a so-called deep copy. (Node implemented fetch on undici after Node 20.x, different between Node 18.x, But I didn't find much difference in their behavior)
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! :)
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! :)
It's probably linked with a version of SvelteKit as well.
I wanted to look into this today, and found the issue and the fix. Perfect timing for me. Thank you 😉
Activity
chenqianhe commentedon Dec 5, 2024
mySelfHandle, because I tried it and everything worked fine:undici, because I checked the source code and found that the clone function infetchprovided byundiciis indeed a so-called deep copy. (Node implemented fetch on undici after Node 20.x, different between Node 18.x, But I didn't find much difference in their behavior)https://github.com/nodejs/undici/blob/9e6d34d6dcf47aed9da997550cba6f158983b20c/lib/web/fetch/request.js#L760
https://github.com/nodejs/undici/blob/9e6d34d6dcf47aed9da997550cba6f158983b20c/lib/web/fetch/body.js#L286
Sentry.sentryHandle()source code, but I really don't have any cluess1gr1d commentedon Dec 5, 2024
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! :)
chenqianhe commentedon Dec 5, 2024
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.
79 remaining items
Lms24 commentedon Feb 11, 2025
Thanks for getting back to us! I'll open a PR then with a fix. If this causes other issues, it's easy to revert, so let's give it a broader try.
jycouet commentedon Feb 14, 2025
It's probably linked with a version of SvelteKit as well.
I wanted to look into this today, and found the issue and the fix. Perfect timing for me. Thank you 😉
I bumped to
9.1.0, now let's see 🚀Lms24 commentedon Mar 4, 2025
I will consider this fixed for now and close the issue. Feel free to tag me if you're still experiencing this issue. Thanks!
Fix: Downgrade to Node 18.x to fix Undici fetch bug