Title: fix(pm-dispatch): ensureWorker caches a rejected promise forever — one transient failure wedges every later launch · Issue #2902 · developing-today/code · GitHub
Open Graph Title: fix(pm-dispatch): ensureWorker caches a rejected promise forever — one transient failure wedges every later launch · Issue #2902 · developing-today/code
X Title: fix(pm-dispatch): ensureWorker caches a rejected promise forever — one transient failure wedges every later launch · Issue #2902 · developing-today/code
Description: Finding QueueClient.ensureWorker() in pm-dispatch memoizes its registration promise with ??= — including when that promise rejects. One transient registration failure (a PostgREST 5xx, a network blip) therefore wedges every subsequent la...
Open Graph Description: Finding QueueClient.ensureWorker() in pm-dispatch memoizes its registration promise with ??= — including when that promise rejects. One transient registration failure (a PostgREST 5xx, a network bl...
X Description: Finding QueueClient.ensureWorker() in pm-dispatch memoizes its registration promise with ??= — including when that promise rejects. One transient registration failure (a PostgREST 5xx, a network bl...
Opengraph URL: https://github.com/developing-today/code/issues/2902
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(pm-dispatch): ensureWorker caches a rejected promise forever — one transient failure wedges every later launch","articleBody":"## Finding\n\n`QueueClient.ensureWorker()` in pm-dispatch memoizes its registration promise with `??=` — including when that promise **rejects**. One transient registration failure (a PostgREST 5xx, a network blip) therefore wedges every subsequent launch for the life of the process: each later `ensureWorker()` returns the same rejected promise and throws the original, stale error.\n\n## Evidence\n\n- PR #2655 (commit `88e2e699e1`, MERGED) introduced `ensureWorker()`.\n- Verified on current main (`c4fb599617166d4c705eabeb34442ca179ecb9a6`), `pm-stack/dispatch/src/queue.ts:132,137-158`:\n\n ```ts\n private workerEnsured: Promise\u003cvoid> | null = null;\n\n ensureWorker(): Promise\u003cvoid> {\n this.workerEnsured ??= (async () => {\n const res = await fetch(`${this.baseUrl}/rest/v1/workers`, { … });\n if (!res.ok) {\n const text = await res.text();\n throw new QueueError(`worker registration failed (HTTP ${res.status}): …`, res.status);\n }\n })();\n return this.workerEnsured;\n }\n ```\n\n There is no `.catch` that resets `workerEnsured` to `null`, and no other code path clears it.\n- Caller order makes it worse: `launchSession` (`src/server.ts:116-129`) creates the OpenCode session and sends the prompt **before** `ensureWorker()` runs. So every launch after the first failure creates a real, running session, then throws at registration — and on the `wait:true` path the task is cancelled and the launch reported FAILED while that session keeps working, untracked.\n\n## Why it matters\n\nRegistration is a one-time, idempotent upsert whose failure modes are overwhelmingly transient — this exact class of failure is what the fleet hit repeatedly on 2026-10-30 (PostgREST 503s during the Supabase outage). A retry-on-next-launch costs nothing; a permanently poisoned cache turns a blip into a dispatch outage that only a service restart fixes, plus a trail of untracked sessions.\n\n## Acceptance criteria\n\n- [ ] A rejected registration attempt is not cached: `workerEnsured` is reset on rejection so the next `ensureWorker()` call retries the upsert (a *successful* registration stays cached).\n- [ ] A unit test covers: first attempt fails (non-OK response or fetch throw), second attempt succeeds, and subsequent calls reuse the success without re-fetching.\n- [ ] No other behaviour of `ensureWorker()` changes (same worker row, same ignore-duplicates upsert).\n\nFound by the pr-diff-review job reviewing PR #2655 (batch 2630–2658, 2026-10-30). Deduped: `gh issue list --search 'ensureWorker worker registration dispatch'` and `'workerEnsured'` (open + all) returned nothing covering this.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-31T01:39:09Z","url":"https://github.com/developing-today/code/issues/2902"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2923d99a-be1e-5f66-f02e-5402a6b9afaa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80B4:29E85A:2858E5:34E83B:6B062D9F |
| html-safe-nonce | f200b88225b6c2522c67f30d06a0f494bee7dcaba421dcb096b429eca9119d11 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEI0OjI5RTg1QToyODU4RTU6MzRFODNCOjZCMDYyRDlGIiwidmlzaXRvcl9pZCI6Ijc3NzcyNjQ5NTAwMjM0MDc2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 62c0f454a696b5631a4fa63f68b229d2eef0ff22ef76da735cd0b4f1031845f9 |
| hovercard-subject-tag | issue:6129711121 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/2902/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b282d4a3fe440925ed6ab6db824f7dfadd253999c1b88e86a7fd224e05ab4b79/developing-today/code/issues/2902 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b282d4a3fe440925ed6ab6db824f7dfadd253999c1b88e86a7fd224e05ab4b79/developing-today/code/issues/2902 |
| og:image:alt | Finding QueueClient.ensureWorker() in pm-dispatch memoizes its registration promise with ??= — including when that promise rejects. One transient registration failure (a PostgREST 5xx, a network bl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width