| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -348,6 +348,34 @@ process.on('multipleResolves', common.mustNotCall()); | |||
| 348 | 348 | assert.strictEqual(loopCount, 5); | |
| 349 | 349 | })); | |
| 350 | 350 | } | |
| 351 | + | ||
| 352 | + { | ||
| 353 | + // Check that if we abort when we have some unresolved callbacks, | ||
| 354 | + // we actually call them. | ||
| 355 | + const controller = new AbortController(); | ||
| 356 | + const { signal } = controller; | ||
| 357 | + const delay = 10; | ||
| 358 | + let totalIterations = 0; | ||
| 359 | + const timeoutLoop = runInterval(async (iterationNumber) => { | ||
| 360 | + await setTimeout(delay * 4); | ||
| 361 | + if (iterationNumber <= 2) { | ||
| 362 | + assert.strictEqual(signal.aborted, false); | ||
| 363 | + } | ||
| 364 | + if (iterationNumber === 2) { | ||
| 365 | + controller.abort(); | ||
| 366 | + } | ||
| 367 | + if (iterationNumber > 2) { | ||
| 368 | + assert.strictEqual(signal.aborted, true); | ||
| 369 | + } | ||
| 370 | + if (iterationNumber > totalIterations) { | ||
| 371 | + totalIterations = iterationNumber; | ||
| 372 | + } | ||
| 373 | + }, delay, signal); | ||
| 374 | + | ||
| 375 | + timeoutLoop.catch(common.mustCall(() => { | ||
| 376 | + assert.ok(totalIterations >= 3, `iterations was ${totalIterations} < 3`); | ||
| 377 | + })); | ||
| 378 | + } | ||
| 351 | 379 | } | |
| 352 | 380 | ||
| 353 | 381 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments