Skip to content

Fix TypeError: Response.clone: Body has already been consumed - #385

Open
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/website-41-response-clone
Open

Fix TypeError: Response.clone: Body has already been consumed#385
seer-by-sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/website-41-response-clone

Conversation

@seer-by-sentry

@seer-by-sentry seer-by-sentry Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR addresses WEBSITE-41, a TypeError: Response.clone: Body has already been consumed. error occurring in src/services/bungie/BungieClient.ts.

Root Cause:
In BaseBungieClient.request(), the response body is consumed by await res.text(). When an error occurs (non-OK response with a Content-Type that is neither application/json nor text/html), the code attempts to create a BungieUnkownHTTPError by calling new BungieUnkownHTTPError(res.clone()). However, res.clone() fails because the response body stream has already been consumed by the preceding res.text() call, leading to the TypeError. This effectively masks the true Bungie API error.

Solution:
Upon investigation, the BungieUnkownHTTPError constructor only utilizes response.status, response.statusText, and response.url from the Response object, and does not require access to the response body. Therefore, cloning the response is unnecessary and problematic after the body has been consumed. The fix involves changing res.clone() to res when instantiating BungieUnkownHTTPError, allowing the original Response object (which still contains the necessary metadata) to be passed directly.

Fixes WEBSITE-41

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
raid-hub Ready Ready Preview Jul 7, 2026 4:22pm

Request Review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants