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

Function testMergeSourceError

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

Source from the content-addressed store, hash-verified

85// =============================================================================
86
87async function testMergeSourceError() {
88 async function* goodSource() {
89 const enc = new TextEncoder();
90 yield [enc.encode('a')];
91 // Slow so the bad source errors first
92 await new Promise((r) => setTimeout(r, 50));
93 yield [enc.encode('b')];
94 }
95
96 async function* badSource() {
97 yield [new TextEncoder().encode('x')];
98 throw new Error('merge source boom');
99 }
100 await assert.rejects(
101 async () => {
102 // eslint-disable-next-line no-unused-vars
103 for await (const _ of merge(goodSource(), badSource())) {
104 /* consume */
105 }
106 },
107 { message: 'merge source boom' },
108 );
109}
110
111async function testMergeConsumerBreak() {
112 let source1Return = false;

Calls 3

goodSourceFunction · 0.85
badSourceFunction · 0.70
mergeFunction · 0.50

Tested by

no test coverage detected