Skip to content

Commit

Permalink
test: add regression test for 51586
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #51491
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Matthew Aitken <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
mcollina authored and richardlau committed Mar 25, 2024
1 parent 6ee5f50 commit f2dfe0f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/parallel/test-webstream-structured-clone-no-leftovers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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);
}
});

0 comments on commit f2dfe0f

Please sign in to comment.