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

Function testPullSignalAbortMidIteration

test/parallel/test-stream-iter-pull-async.js:140–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

138
139// Pull signal aborted mid-iteration (not pre-aborted)
140async function testPullSignalAbortMidIteration() {
141 const ac = new AbortController();
142 const enc = new TextEncoder();
143 async function* slowSource() {
144 yield [enc.encode('a')];
145 yield [enc.encode('b')];
146 yield [enc.encode('c')];
147 }
148 const result = pull(slowSource(), { signal: ac.signal });
149 const iter = result[Symbol.asyncIterator]();
150 const first = await iter.next(); // Read first batch
151 assert.strictEqual(first.done, false);
152 ac.abort();
153 await assert.rejects(() => iter.next(), { name: 'AbortError' });
154}
155
156async function testPullSignalAbortWhileSourceNextPending() {
157 const source = {

Callers 1

Calls 4

abortMethod · 0.95
pullFunction · 0.70
slowSourceFunction · 0.70
nextMethod · 0.65

Tested by

no test coverage detected