Procházet zdrojové kódy

test(admission-runtime): close the unhandled-rejection window in teardown test

CI flake (seen on the #1194 run, both Bun jobs): the teardown timer
rejects queued.ready inside its own macrotask, while the test attached
its rejection handler only after the following await — leaving a
macrotask-wide window where the rejection is unhandled, which the CI
runtimes report as a test failure (local runs attach fast enough to
stay green). Pre-existing since 0edc4774; unrelated to this PR's
changes, but it blocks the Required checks.

Capture the outcome synchronously before owner.release() so the
handler is attached ahead of any rejection; assertions unchanged
(cancellation message, idempotent double release, empty snapshot).
Stress: 20/20 green.
GoldJohnKing před 2 dny
rodič
revize
f8b95b2643
1 změnil soubory, kde provedl 12 přidání a 1 odebrání
  1. 12 1
      src/admission-runtime.test.ts

+ 12 - 1
src/admission-runtime.test.ts

@@ -87,10 +87,21 @@ describe('admission runtime leases', () => {
       concurrencyTicket: queued,
     });
 
+    // Attach the outcome capture BEFORE teardown: the teardown timer
+    // rejects `queued.ready` inside its own macrotask, and a handler
+    // attached only after the following `await` leaves an
+    // unhandled-rejection window that CI runtimes can report as a test
+    // failure (seen on the #1194 CI run; the window exists regardless
+    // of runner speed).
+    const queuedOutcome = queued.ready.then(
+      () => 'resolved',
+      (error: unknown) => String((error as Error)?.message),
+    );
+
     owner.release();
     owner.release();
     await new Promise((resolve) => setTimeout(resolve, 0));
-    await expect(queued.ready).rejects.toThrow(
+    expect(await queuedOutcome).toBe(
       'Background task concurrency queue was cancelled',
     );
     expect(owner.backgroundTaskConcurrency.snapshot()).toEqual({