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
Remix: Throwing a 4XX/5XX Response causes a "body already used for" error #5423
You would then use a remix CatchBoundary to catch the 404 and display a message. To reproduce, just add the loader above to any route and try to open the page.
Expected Result
Sentry should pass the 404 through and allow the CatchBoundary to show it. It worked fine in 7.6.0.
Actual Result
As of 7.7.0, @sentry/remix is causing the following error when loading any page that throws a response. It only happens if the page was server rendered, e.g. given a route /foo that throws a 404, if I load /foo directly and it server renders, it crashes with the error below. If I load / first, then navigate client-side to /foo, it uses the catch boundary properly. I assume this is related to the updates in #5405 since it worked fine in 7.6.0 and that PR addressed some thrown responses.
TypeError: body used already for:
at consumeBody (/Users/dylan/dev/smp/node_modules/@remix-run/web-fetch/src/body.js:205:9)
at NodeResponse.text (/Users/dylan/dev/smp/node_modules/@remix-run/web-fetch/src/body.js:171:24)
at Object.extractData (/Users/dylan/dev/smp/node_modules/@remix-run/server-runtime/dist/data.js:138:19)
at handleDocumentRequest (/Users/dylan/dev/smp/node_modules/@remix-run/server-runtime/dist/server.js:331:28)
at requestHandler (/Users/dylan/dev/smp/node_modules/@remix-run/server-runtime/dist/server.js:49:18)
at /Users/dylan/dev/smp/node_modules/@sentry/remix/cjs/utils/instrumentServer.js:167:16
at /Users/dylan/dev/smp/node_modules/@remix-run/express/dist/server.js:39:22
It's just raw text from the server, not handled by any ErrorBoundary. If I throw a standard Error object instead, it uses the ErrorBoundary.
Activity
alexblack commentedon Jul 16, 2022
I hit this too: #5425
onurtemizkan commentedon Jul 18, 2022
Thanks for reporting this @dmarkow and @alexblack!
Opened a PR to fix it! #5429
fix(remix): Clone erroneous responses not to consume their body strea…