-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
A ReadableStream branch was created but never consumed #648
Comments
PR welcome to fix this issue. If I'm not mistaken, canceling the stream could lead to lost data even though we've cloned the stream. We'd need to test it thoroughly to make sure that's not the case. |
Clean up orphan ReadableStream remaining during parsing response (sindresorhus#648)
I‘m willing to do so, and a PR have already been submitted . export default {
async fetch (): Promise<Response> {
const originalResponse = new Response("Some Data");
const clonedResponse = originalResponse.clone();
await originalResponse.body?.cancel();
console.log("Original Stream Data:", await originalResponse.body?.getReader().read());
console.log("Cloned Stream Data:", await clonedResponse.body?.getReader().read());
return new Response("");
}
} satisfies ExportedHandler; I cloned an unconsumed response and canceled the The result is as follows:
The original ReadableStream has already been canceled, but the cloned response has an independent ReadableStream object that can be consumed. |
There is also a similar issue about orphan ReadableStream remaining. Related to :#650 |
I'm using ky in cloudflare worker with following code:
and when I turn off local mode, requests raise the following warning:
Locate the following code snippet:
source/core/Ky.ts
The
awaitedResult
is a variable of type Response. Since it is declared, it has been cloned only once, and its ReadableStream has never been consumed.After
awaitedResult
has finished cloning, its ReadableStream should be closed to ensure memory safety.Seems like:
The text was updated successfully, but these errors were encountered: