nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
108.03k stars 29.82k forks source link

Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF #43325

Open masx200 opened 2 years ago

masx200 commented 2 years ago

Version

v18.3.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

No response

What steps will reproduce the bug?

import stream from "stream";

await test2();

async function test2() {
    console.log("good");
    const readable = stream.Readable.from("11111222222222".repeat(999));

    const readableStream = stream.Readable.toWeb(readable);
    const [stream1, stream2] = readableStream.tee();
    //good
    //
    const streams = [stream1, stream2];
    await Promise.all(
        streams.map(async (temp) => {
            console.log(temp);
            for await (const data of stream.Readable.fromWeb(temp)) {
                console.log(data);
            }
        })
    );
}

await test1();

async function test1() {
    console.log("error");
    const readable = stream.Readable.from("11111222222222".repeat(999));

    const readableStream = stream.Readable.toWeb(readable);
    const [stream1, stream2] = readableStream.tee();
    //error
    console.log(stream1);
    for await (const data of stream.Readable.fromWeb(stream1)) {
        console.log(data);
    }
    console.log(stream2);
    for await (const data of stream.Readable.fromWeb(stream2)) {
        console.log(data);
    }
}
 node "C:\Documents\test\test.mjs"

How often does it reproduce? Is there a required condition?

100% occur.

What is the expected behavior?

no errors

What do you see instead?


good
ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
<Buffer 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 ... 13936 more bytes>
<Buffer 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 ... 13936 more bytes>
error
ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
<Buffer 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 32 32 32 32 32 32 31 31 31 31 31 32 32 32 ... 13936 more bytes>
ReadableStream { locked: false, state: 'readable', supportsBYOB: false }
node:internal/process/esm_loader:91
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_STREAM_PUSH_AFTER_EOF]: stream.push() after EOF
    at new NodeError (node:internal/errors:377:5)
    at readableAddChunk (node:internal/streams/readable:285:30)
    at Readable.push (node:internal/streams/readable:234:10)
    at node:internal/webstreams/adapters:481:22
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_STREAM_PUSH_AFTER_EOF'
}

Node.js v18.3.0

Additional information

No response

davedoesdev commented 2 years ago

Is this a duplicate of https://github.com/nodejs/node/issues/42694 ?

y1d7ng commented 7 months ago

@masx200 Looks like the latest version doesn't have this issue anymore. cc @VoltrexKeyva

huseyinacacak-janea commented 3 weeks ago

Hi @masx200, I wanted to look into this issue but wasn't able to reproduce it (I tried Node.js v18.20.4, v20.18.0, v22.10.0, and v23.1.0). Do you think this issue can be closed now?