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 <hello@matteocollina.com>
PR-URL: #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>
  • Loading branch information
mcollina authored and RafaelGSS committed Jan 19, 2024
1 parent 662ac95 commit 1b8bba8
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 1b8bba8

Please sign in to comment.