Version
v20.16.0
Platform
23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:19:05 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8112 arm64
Subsystem
stream
What steps will reproduce the bug?
Two separate test cases:
const { Readable } = require('node:stream');
const r = Readable.from(['data']);
const wrapper = Readable.fromWeb(Readable.toWeb(r));
wrapper.on('data', () => {
wrapper.destroy();
});
and
const { Readable } = require('node:stream');
const r = new Readable({
read() {
this.push(null);
},
});
r.on('close', () => reader.cancel());
const reader = Readable.toWeb(r).getReader();
reader.read();
How often does it reproduce? Is there a required condition?
100% reproducible using script above
What is the expected behavior? Why is that the expected behavior?
An exception should not be thrown.
What do you see instead?
node:internal/webstreams/readablestream:1042
throw new ERR_INVALID_STATE.TypeError('Controller is already closed');
^
TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed
at ReadableStreamDefaultController.close (node:internal/webstreams/readablestream:1042:13)
at Readable.<anonymous> (node:internal/webstreams/adapters:451:16)
at Readable.<anonymous> (node:internal/util:525:20)
at Readable.onclose (node:internal/streams/end-of-stream:162:14)
at Readable.emit (node:events:531:35)
at emitCloseNT (node:internal/streams/destroy:147:10)
at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'ERR_INVALID_STATE'
}
And there doesn't seem to be a way to catch this exception.
Additional information
No response
Version
v20.16.0
Platform
Subsystem
stream
What steps will reproduce the bug?
Two separate test cases:
and
How often does it reproduce? Is there a required condition?
100% reproducible using script above
What is the expected behavior? Why is that the expected behavior?
An exception should not be thrown.
What do you see instead?
And there doesn't seem to be a way to catch this exception.
Additional information
No response