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

Function testMergeCleanupErrorOnly

test/parallel/test-stream-iter-consumers-merge.js:199–221  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197// Cleanup error with no primary error: iterator.return() throws during
198// normal completion. The cleanup error should propagate directly.
199async function testMergeCleanupErrorOnly() {
200 async function* source() {
201 yield [new TextEncoder().encode('data')];
202 }
203
204 async function* failingReturnSource() {
205 try {
206 yield [new TextEncoder().encode('more')];
207 } finally {
208 throwInFinally('cleanup boom');
209 }
210 }
211
212 await assert.rejects(
213 async () => {
214 // eslint-disable-next-line no-unused-vars
215 for await (const _ of merge(source(), failingReturnSource())) {
216 // Consume all - no primary error
217 }
218 },
219 { message: 'cleanup boom' },
220 );
221}
222
223// Primary error + cleanup error: a source throws during iteration AND
224// iterator.return() also throws. Should get a SuppressedError.

Calls 3

failingReturnSourceFunction · 0.85
sourceFunction · 0.70
mergeFunction · 0.50

Tested by

no test coverage detected