Repository navigation
fix(pm-dispatch): reset ensureWorker memo on rejection (#2902) - #2908
Conversation
ensureWorker memoised its registration promise with ??=, including when it rejected: one transient PostgREST 5xx or network blip wedged every later launch for the life of the process, each returning the same stale rejected promise -- and launchSession had already created a real session before throwing. The memo now resets on rejection (the reset runs inside the catch, before the rejection reaches any awaiting caller; a successful registration stays cached). Worker row and ignore-duplicates upsert unchanged. New test/queue.test.ts: first attempt fails (HTTP 503), second succeeds, later calls reuse the success without re-fetching; a fetch throw also resets; concurrent callers share one attempt and one retry. Verified on laptop: bun test 42 pass / 0 fail (tsc --noEmit cannot run here -- @types/bun not installed, identical failure on clean main).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 27 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fixes #2902 (queue task 4131).
QueueClient.ensureWorker()memoised its registration promise with??=— including when it rejected. One transient registration failure (PostgREST 5xx, network blip) wedged every later launch for the life of the process, andlaunchSessionhad already created a real session before the throw.Change (
pm-stack/dispatch/src/queue.ts): the memoised promise gets a.catchthat resetsworkerEnsuredto null before rethrowing — the reset runs before the rejection reaches any awaiting caller, and no newer attempt can have replaced the memo in between (a new attempt is only assigned while the memo is null, and this catch is the only place that nulls it). A successful registration stays cached. Worker row contents and the ignore-duplicates upsert are unchanged.Tests (new
pm-stack/dispatch/test/queue.test.ts):Verified on the laptop:
bun test— 42 pass / 0 fail across the dispatch suite. (bunx tsc --noEmitcannot run in this environment —@types/bunis not installed; it fails identically on clean main.)Need help on this PR? Tag
@codesmith-botwith what you need.