0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-webstream-structured-clone-no-leftovers.mjs
Matteo Collina fbf1fb3bed test: add regression test for 51586
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: https://github.com/nodejs/node/pull/51491
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2024-01-19 11:47:06 +00:00

29 lines
659 B
JavaScript

import '../common/index.mjs';
import { test } from 'node:test';
import assert from 'node:assert';
test('do not leak promises', async () => {
const buf = new Uint8Array(1);
const readable = new ReadableStream({
start(controller) {
controller.enqueue(buf);
controller.close();
}
});
const [out1, out2] = readable.tee();
const cloned = structuredClone(out2, { transfer: [out2] });
for await (const chunk of cloned) {
assert.deepStrictEqual(chunk, buf);
}
for await (const chunk of out2) {
assert.deepStrictEqual(chunk, buf);
}
for await (const chunk of out1) {
assert.deepStrictEqual(chunk, buf);
}
});