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

Function testShareAbortSignal

test/parallel/test-stream-iter-share-async.js:135–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135async function testShareAbortSignal() {
136 const ac = new AbortController();
137 const reason = new Error('share aborted');
138 const enc = new TextEncoder();
139 async function* source() {
140 yield [enc.encode('a')];
141 yield [enc.encode('b')];
142 }
143 const shared = share(source(), {
144 highWaterMark: 1,
145 backpressure: 'block',
146 signal: ac.signal,
147 });
148 const fast = shared.pull()[Symbol.asyncIterator]();
149 shared.pull();
150
151 await fast.next();
152 const read = fast.next();
153 const rejected = assert.rejects(read, (error) => error === reason);
154 ac.abort(reason);
155
156 await rejected;
157}
158
159async function testShareAbortSignalWhileSourcePullPending() {
160 const ac = new AbortController();

Callers 1

Calls 5

abortMethod · 0.95
shareFunction · 0.85
sourceFunction · 0.70
nextMethod · 0.65
pullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…