-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
ReadableStream is missing asyncIterator and cancel does not cancel #19946
Comments
I am using deno 1.35.1. Running |
I can' t reproduce the asyniterator ts error, with deno1.35.2 linux |
There seem to be multiple bugs?,
iterating manually instead of the for await, fixes both issues const reader = lines.getReader();
while (true) {
const { done, value } = await reader.read();
console.log(value);
if (done) break;
} |
CC @marvinhagemeister IIRC, you hit the same problem recently. Any chance you could summarize what we discovered? |
@sigmaSd Yes, there are possible workarounds. Not reading all the lines is intentional - it exposes the problem. I am not sure if there is an actual leak or if the test runner is miscomplaining. My understanding is that the wrt async iterator - the thing is that I get the type check error with plain I've upgraded to 1.35.3 and I still get TS2504 error. @marvinhagemeister I found this in when the server outputs anything to stdout, I get the leak report. |
The |
@sigmaSd I was trying the workaround. Once the async iteration is started, reading the stream to the end (async or otherwise) does not help. So what I had to do was to replace https://github.com/denoland/fresh/blob/efbff06fcaf30e8a5600d9fd299b75ed590c31b8/tests/test_utils.ts#L130-L136 with the reader implementation. After that I deleted https://github.com/denoland/fresh/blob/efbff06fcaf30e8a5600d9fd299b75ed590c31b8/tests/test_utils.ts#L36 and added draining the stream after sending SIGTERM to the server process. That got rid off the leak. I don't have enough understanding to say if #13142 is indeed a duplicate or not. What I am seeing is a leak if a started async iteration is not followed to the end. It might be the same thing if that counts as an "error", I don't know. |
The test worked for me import { TextLineStream } from "https://deno.land/std@0.195.0/streams/text_line_stream.ts";
Deno.test("a", async () => {
const res = await fetch("https://example.com");
const lines = res.body!
.pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream());
for await (const line of lines) {
console.log(line);
break;
}
await lines.cancel();
}); version:
|
I think my issue is connected to this one so I will paste it here. Deno.test('stream iterator fail', async () => {
const stream = new ReadableStream<Uint8Array>();
const it = stream[Symbol.asyncIterator]();
await it.next();
await it.return?.();
console.log('Stream closed');
}); Results with:
version:
|
Working with the example from https://deno.land/std@0.195.0/streams/text_line_stream.ts?s=TextLineStream:
Running this test with
deno test
results first in TS2504 error:If I run it with
--no-check
I get a different error:I am not sure if
test
is wrongly detecting a leak or if there is an actual leak but there does not seem to be anything else to do with the stream butcancel
. It seems there is no error-free way out for this test to finish successfuly.The text was updated successfully, but these errors were encountered: