Closed
Description
Version
v22.14.0
Platform
Darwin mba.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103 arm64
Subsystem
Web Streams
What steps will reproduce the bug?
const writable = new WritableStream({
write(chunk) {
console.log(chunk)
}
})
const writer = writable.getWriter()
await writer.write('Hello')
await writer.close() // closes the stream
try {
await writer.write('World') // write after closed
} catch (e) {
console.error(e)
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
When this program runs, it should print something like the following:
Hello
TypeError [ERR_INVALID_STATE]: Invalid state: WritableStream is closed
at writableStreamDefaultWriterWrite (node:internal/webstreams/writablestream:997:7)
at WritableStreamDefaultWriter.write (node:internal/webstreams/writablestream:442:12)
at <anonymous> (/Users/ayon/Workspace/try-out/main2.ts:14:18) {
code: 'ERR_INVALID_STATE'
}
The correct behavior is that after the stream is closed, continuing to write will cause a TypeError
saying that the stream is closed.
What do you see instead?
Instead, the new version of Node.js v22.14.0 prints this:
Hello
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues
at assert (node:internal/assert:11:11)
at writableStreamDefaultControllerGetChunkSize (node:internal/webstreams/writablestream:1184:5)
at writableStreamDefaultWriterWrite (node:internal/webstreams/writablestream:983:21)
at WritableStreamDefaultWriter.write (node:internal/webstreams/writablestream:443:12)
at <anonymous> (/Users/ayon/Workspace/try-out/main2.ts:13:18) {
code: 'ERR_INTERNAL_ASSERTION'
}
Additional information
The correct behavior is consistent with Deno, Bun, the browser, and previous Node.js versions, i.e. v22.13.1
and before, but recent versions, such as v22.14.0
, are broken.
Metadata
Metadata
Assignees
Labels
No labels