node/test/parallel/test-whatwg-writablestream-close.js
Daeyeon Jeong c566639026
stream: fix sizeAlgorithm validation in WritableStream
Signed-off-by: Daeyeon Jeong <daeyeon.dev@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/57280
Fixes: https://github.com/nodejs/node/issues/57272
Refs: https://github.com/nodejs/node/pull/56067
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
2025-03-05 03:04:39 +00:00

29 lines
556 B
JavaScript

'use strict';
require('../common');
const { test } = require('node:test');
const assert = require('node:assert');
// https://github.com/nodejs/node/issues/57272
test('should throw error when writing after close', async (t) => {
const writable = new WritableStream({
write(chunk) {
console.log(chunk);
},
});
const writer = writable.getWriter();
await writer.write('Hello');
await writer.close();
await assert.rejects(
async () => {
await writer.write('World');
},
{
name: 'TypeError',
}
);
});