fix(browser): release discarded source-map response bodies (#611)

* fix(browser): release discarded source-map response bodies

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>

* test(browser): preserve unknown with-scope loader bindings

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>

---------

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-06 02:09:50 +08:00
committed by GitHub
parent b81d18eeee
commit 864205570a
2 changed files with 88 additions and 1 deletions
+4 -1
View File
@@ -87,12 +87,14 @@ const fetchOne = async (
"A source-map redirect left the approved exact origins.",
);
const { response, fetchedUrl } = fetched;
if (!response.ok)
if (!response.ok) {
await response.body?.cancel();
return emptySourceMapItem(
request,
"fetch_failed",
`Source-map server returned HTTP ${String(response.status)}.`,
);
}
return normalizeSourceMap(request, await response.text(), fetchedUrl);
} catch (cause: unknown) {
if (signal?.aborted === true) throw cause;
@@ -130,6 +132,7 @@ const fetchFollowingApprovedRedirects = async (
return { response, fetchedUrl: current };
const location = response.headers.get("location");
if (location === null) return { response, fetchedUrl: current };
await response.body?.cancel();
current = new URL(location, current).href;
}
};