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

Function testShareSyncSourceError

test/parallel/test-stream-iter-share-sync.js:127–145  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125// =============================================================================
126
127function testShareSyncSourceError() {
128 function* failingSource() {
129 yield [new TextEncoder().encode('ok')];
130 throw new Error('sync share boom');
131 }
132 const shared = shareSync(failingSource());
133 const c1 = shared.pull();
134 const c2 = shared.pull();
135
136 // Both consumers should see the error
137 assert.throws(() => {
138 // eslint-disable-next-line no-unused-vars
139 for (const _ of c1) { /* consume */ }
140 }, { message: 'sync share boom' });
141 assert.throws(() => {
142 // eslint-disable-next-line no-unused-vars
143 for (const _ of c2) { /* consume */ }
144 }, { message: 'sync share boom' });
145}
146
147// shareSync() accepts string source directly (normalized via fromSync())
148function testShareSyncStringSource() {

Callers 1

Calls 3

shareSyncFunction · 0.85
failingSourceFunction · 0.70
pullMethod · 0.45

Tested by

no test coverage detected