MCPcopy Create free account
hub / github.com/nodejs/node / testBroadcastWriteAbort

Function testBroadcastWriteAbort

test/parallel/test-stream-iter-broadcast-coverage.js:16–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14
15// Signal abort on pending write (covers wireBroadcastWriteSignal + removeAt)
16async function testBroadcastWriteAbort() {
17 const { writer, broadcast: bc } = broadcast({
18 highWaterMark: 1,
19 backpressure: 'block',
20 });
21 const consumer = bc.push();
22
23 // Fill the buffer to capacity
24 writer.writeSync(new Uint8Array([1]));
25
26 // Next write will block — pass a signal
27 const ac = new AbortController();
28 const writePromise = writer.write(new Uint8Array([2]),
29 { signal: ac.signal });
30
31 // Abort the signal
32 ac.abort();
33
34 await assert.rejects(writePromise, { name: 'AbortError' });
35
36 // Clean up
37 writer.endSync();
38 // Drain the consumer
39 const result = [];
40 for await (const batch of consumer) {
41 result.push(...batch);
42 }
43 assert.ok(result.length >= 1);
44}
45
46// Broadcast.from with sync iterable (generator)
47async function testBroadcastFromSyncIterable() {

Calls 7

abortMethod · 0.95
broadcastFunction · 0.50
pushMethod · 0.45
writeSyncMethod · 0.45
writeMethod · 0.45
endSyncMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected