| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 32bb197 commit a9dc50d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -764,6 +764,10 @@ async function* createAsyncPipeline(source, transforms, signal) { | |||
| 764 | 764 | controller.signal.throwIfAborted(); | |
| 765 | 765 | yield batch; | |
| 766 | 766 | } | |
| 767 | + // A transform can abort while completing without producing a final batch, | ||
| 768 | + // for example when an async flush resolves to null. In that case the loop | ||
| 769 | + // body has no opportunity to observe the abort. | ||
| 770 | + controller.signal.throwIfAborted(); | ||
| 767 | 771 | completed = true; | |
| 768 | 772 | } catch (error) { | |
| 769 | 773 | if (!controller.signal.aborted) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -295,6 +295,23 @@ async function testPullStatelessTransformFlushError() { | |||
| 295 | 295 | }, { message: 'async flush boom' }); | |
| 296 | 296 | } | |
| 297 | 297 | ||
| 298 | + // An abort during an async flush must not be swallowed when the flush resolves | ||
| 299 | + // to null and therefore produces no final batch. | ||
| 300 | + async function testPullSignalAbortDuringAsyncFlush() { | ||
| 301 | + const ac = new AbortController(); | ||
| 302 | + const reason = new Error('aborted during flush'); | ||
| 303 | + const transform = async (chunks) => { | ||
| 304 | + if (chunks !== null) return chunks; | ||
| 305 | + ac.abort(reason); | ||
| 306 | + return null; | ||
| 307 | + }; | ||
| 308 | + | ||
| 309 | + await assert.rejects( | ||
| 310 | + () => text(pull(from('x'), transform, { signal: ac.signal })), | ||
| 311 | + (error) => error === reason, | ||
| 312 | + ); | ||
| 313 | + } | ||
| 314 | + | ||
| 298 | 315 | // Pull with a sync iterable source (not async) | |
| 299 | 316 | async function testPullWithSyncSource() { | |
| 300 | 317 | function* gen() { | |
@@ -409,6 +426,7 @@ async function testTransformOptionsNotShared() { | |||
| 409 | 426 | testPullStatelessTransformFlush(), | |
| 410 | 427 | testPullConsecutiveStatelessTransformFlush(), | |
| 411 | 428 | testPullStatelessTransformFlushError(), | |
| 429 | + testPullSignalAbortDuringAsyncFlush(), | ||
| 412 | 430 | testPullWithSyncSource(), | |
| 413 | 431 | testPullStringSource(), | |
| 414 | 432 | testTransformReturnsSingleUint8Array(), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments