Commit 53a0f82
authored
fix(namespaces): deterministic catalog storageFor test (kill setTimeout flake) (#1564)
The "StorageRouter integration: catalog registers namespace on storageFor"
test relied on `await new Promise((r) => setTimeout(r, 10))` to let a
fire-and-forget `catalog.registerResolved(...)` — fired from the router's
`onResolve` hook inside `storageFor()` — settle before asserting the record
exists. Under CI contention 10ms was not always enough, so the assertion
intermittently failed (observed on an unrelated PR's quality job, passing on
rerun).
Add `NamespaceStorageRouter.whenResolveHooksSettled()`: the router now tracks
in-flight resolve-hook promises in a `pendingResolveHooks` set (added before
awaiting, removed when each settles — same lifecycle as `inFlightResolved`, so
it cannot grow unbounded). Callers can await it to observe the fire-and-forget
registrations `storageFor()` kicks off, deterministically, with no timer.
Replace the sleep in the target test and 4 sibling router-dedup tests with
`await router.whenResolveHooksSettled()`. Additive-only; no change to storage
resolution behavior.
Left unrelated setTimeout uses alone: the lock-release timing test and the
bounded `Promise.race` deadlock guards / interleaving seam settles.
Verified: 16 clean runs (10 sequential + 6 parallel under 8 saturated CPU
cores), 87/87 each; `tsc --noEmit`, preflight:quick, and entity-hardening
(245/245) all green. Independent of the #1546 category-dir work (PR #1563).1 parent 41fff8c commit 53a0f82
2 files changed
Lines changed: 40 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
490 | | - | |
491 | | - | |
492 | | - | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
| 495 | + | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| |||
2523 | 2523 | | |
2524 | 2524 | | |
2525 | 2525 | | |
2526 | | - | |
2527 | | - | |
| 2526 | + | |
| 2527 | + | |
2528 | 2528 | | |
2529 | 2529 | | |
2530 | 2530 | | |
| |||
2564 | 2564 | | |
2565 | 2565 | | |
2566 | 2566 | | |
2567 | | - | |
| 2567 | + | |
2568 | 2568 | | |
2569 | 2569 | | |
2570 | 2570 | | |
| |||
2589 | 2589 | | |
2590 | 2590 | | |
2591 | 2591 | | |
2592 | | - | |
2593 | | - | |
| 2592 | + | |
| 2593 | + | |
2594 | 2594 | | |
2595 | 2595 | | |
2596 | 2596 | | |
2597 | 2597 | | |
2598 | 2598 | | |
2599 | 2599 | | |
2600 | | - | |
| 2600 | + | |
2601 | 2601 | | |
2602 | 2602 | | |
2603 | 2603 | | |
2604 | 2604 | | |
2605 | | - | |
| 2605 | + | |
2606 | 2606 | | |
2607 | 2607 | | |
2608 | 2608 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
226 | 231 | | |
227 | 232 | | |
228 | 233 | | |
| |||
325 | 330 | | |
326 | 331 | | |
327 | 332 | | |
328 | | - | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
329 | 337 | | |
330 | 338 | | |
331 | 339 | | |
| |||
338 | 346 | | |
339 | 347 | | |
340 | 348 | | |
| 349 | + | |
341 | 350 | | |
342 | 351 | | |
343 | 352 | | |
| |||
348 | 357 | | |
349 | 358 | | |
350 | 359 | | |
| 360 | + | |
351 | 361 | | |
352 | 362 | | |
353 | 363 | | |
| |||
358 | 368 | | |
359 | 369 | | |
360 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
361 | 388 | | |
0 commit comments