MCPcopy Index your code
hub / github.com/nodejs/node / testBlockWaitsForDrain

Function testBlockWaitsForDrain

test/parallel/test-stream-iter-writable-interop.js:87–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85// =============================================================================
86
87async function testBlockWaitsForDrain() {
88 const chunks = [];
89 const writable = new Writable({
90 highWaterMark: 1, // Very small buffer
91 write(chunk, encoding, cb) {
92 chunks.push(Buffer.from(chunk));
93 // Delay callback to simulate slow consumer
94 setTimeout(cb, 10);
95 },
96 });
97
98 const writer = fromWritable(writable, { backpressure: 'block' });
99
100 await writer.write('a');
101 await writer.write('b');
102 await writer.write('c');
103 await writer.end();
104
105 assert.strictEqual(Buffer.concat(chunks).toString(), 'abc');
106}
107
108// =============================================================================
109// block: stream error rejects pending write

Calls 5

fromWritableFunction · 0.85
concatMethod · 0.80
writeMethod · 0.45
endMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected