Repository navigation
fix(gateway): prevent public chat 503s after startup - #167604
Conversation
Construct resident Gateway resources outside the transient startup work scope. The CLI closes that scope after successful boot; HTTP listeners must not inherit its aborted signal on later session reads. Keep the startup promise tracked and the explicit cancellation signal, Tailscale cleanup, and SDK-host context intact. This repairs the lifetime regression introduced by 7d18caf (#167514). The unchanged real-Gateway command-palette flow reproduces the 503 on the producer and passes with this change. Interrupted-start and Tailscale ownership tests retain their existing assertions. P2 review is clean.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesConstructs resident Gateway resources outside the temporary startup work scope while preserving explicit startup cancellation and cleanup. Example: Open /chat/main after Gateway startup
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness✅ Ready for maintainer review This PR repairs a current-main startup-lifetime regression with a focused change and matching real-Gateway regression evidence. No actionable patch defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway starts HTTP listeners and session readers that remain active after boot completes. Its temporary startup scope joins boot work, while resident resources and normal shutdown have separate lifetimes. flowchart TD
A[Gateway CLI startup] --> B[Temporary startup scope]
B --> C[Tracked startup promise]
C --> D[Resident Gateway construction]
B --> E[Explicit cancellation signal]
E --> F[Tailscale startup cleanup]
D --> G[HTTP listeners and session readers]
G --> H[Chat response after boot]
Technical reviewBest possible solution: Keep resident Gateway resources under their normal runtime lifetime while startup owns its returned promise and explicit cancellation cleanup. Do we have a high-confidence way to reproduce the issue? Yes: the unchanged real-Gateway browser flow provides a concrete reproduction path, and source explains how successful boot aborts the scope inherited by later session reads. The reviewer did not execute that path. Is this the best way to solve the issue? Yes: detaching resident construction at the startup owner fixes the lifetime mismatch without weakening session-read checks or duplicating HTTP-specific recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 62355575c041. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4. Total +4 across 1 file. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 9, 2026, 12:32 AM ET / 04:32 UTC. |
Construct resident Gateway resources outside the transient startup work scope. The CLI closes that scope after successful boot; HTTP listeners must not inherit its aborted signal on later session reads. Keep the startup promise tracked and the explicit cancellation signal, Tailscale cleanup, and SDK-host context intact. This repairs the lifetime regression introduced by cc82cda (openclaw#167514). The unchanged real-Gateway command-palette flow reproduces the 503 on the producer and passes with this change. Interrupted-start and Tailscale ownership tests retain their existing assertions. P2 review is clean.
…upted (#167514) A Gateway restarted during startup could leave the root tailscale serve it launched through sudo -n holding HTTPS 443: the route-owner worker signaled the sudo-owned group without privilege, and startup only published Tailscale cleanup after readiness, so every later start refused with exit 78 until the process was killed by hand. The worker now stops its owned process group through sudo -n and reports a stop failure with the exact command; startup cancellation reaches backend readiness, the route claim and hostname lookup, and stops the serve it started. Unproven foreign routes are still never touched; the refusal now names how to find and stop the claimant. Closes #167436. Reported by @pandysp. (cherry picked from commit 7d18caf) Backport adaptation: kept the release's manual startup-timeout promise (adding the abort listener and stop-failed handling there instead of raceWithTimeout) and its hostname catch, and folded in the runOutsideAsyncWorkScope follow-up from 14b9d90 (#167604) so resident listeners do not inherit the closed startup scope.
Construct resident Gateway resources outside the transient startup work scope. The CLI closes that scope after successful boot; HTTP listeners must not inherit its aborted signal on later session reads. Keep the startup promise tracked and the explicit cancellation signal, Tailscale cleanup, and SDK-host context intact. This repairs the lifetime regression introduced by 7d18caf (#167514). The unchanged real-Gateway command-palette flow reproduces the 503 on the producer and passes with this change. Interrupted-start and Tailscale ownership tests retain their existing assertions. P2 review is clean. (cherry picked from commit 14b9d90)
…when Serve is denied (#171819) * fix(gateway): stop the Tailscale serve process when a start is interrupted (#167514) A Gateway restarted during startup could leave the root tailscale serve it launched through sudo -n holding HTTPS 443: the route-owner worker signaled the sudo-owned group without privilege, and startup only published Tailscale cleanup after readiness, so every later start refused with exit 78 until the process was killed by hand. The worker now stops its owned process group through sudo -n and reports a stop failure with the exact command; startup cancellation reaches backend readiness, the route claim and hostname lookup, and stops the serve it started. Unproven foreign routes are still never touched; the refusal now names how to find and stop the claimant. Closes #167436. Reported by @pandysp. Backport adaptation: 2026.9.33 has no raceWithTimeout, so startTailscaleRouteOwner keeps its manual startupTimer promise and gains the stop-failed branch plus an abort listener that settles startup with the signal reason and is removed on settle. The 9.33 racePromiseWithAbortSignal takes no reason mapper, so the hostname race catches its abort-only rejection and rethrows the signal reason through throwIfAborted; the 9.33 .catch(() => null) on the hostname lookup is kept. server-start.ts keeps the 9.33 kernel destructure including beginClosePrelude and adds tailscaleStopping/stopStartingTailscale. The claim test keeps the 9.33 it.for authority matrix and adds the cancelled-claim case. (cherry picked from commit 7d18caf) * fix(gateway): keep local access when tailnet denies Serve (#171509) Backport adaptation: 2026.9.33 keeps the manual startupTimer promise instead of raceWithTimeout, so the timer callback sets startupDeadlineExpired before settling and routeClaimError receives mode and that flag from the worker failure handler. The stop-failure check sits on the 9.33 waitWithTimeout helper instead of settlesWithin. The claim test drops main's stopped-daemon test, which was only diff context and depends on backend-stopped handling that 9.33 does not ship. (cherry picked from commit f122878) * fix(gateway): reject Tailscale startup with an Error when the claim is interrupted * fix(gateway): prevent public chat 503s after startup (#167604) Construct resident Gateway resources outside the transient startup work scope. The CLI closes that scope after successful boot; HTTP listeners must not inherit its aborted signal on later session reads. Keep the startup promise tracked and the explicit cancellation signal, Tailscale cleanup, and SDK-host context intact. This repairs the lifetime regression introduced by 7d18caf (#167514). The unchanged real-Gateway command-palette flow reproduces the 503 on the producer and passes with this change. Interrupted-start and Tailscale ownership tests retain their existing assertions. P2 review is clean. (cherry picked from commit 14b9d90) --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes public chat links returning HTTP 503 after a successful Gateway startup instead of the normal not-found/login response.
User Impact
Public chat requests can read session state after startup completes. Interrupted startup still cancels and joins its Tailscale cleanup. No configuration, schema, or stored-state migration is involved.
Why This Change Was Made
An adjacent-commit bisect identifies
7d18cafe121a(#167514): server construction began running inside the startup work scope, which the CLI closes after successful boot. Resident HTTP resources inherited that already-aborted scope, so later reads returned “This conversation is temporarily unavailable.”Construct resident resources outside the temporary work scope while preserving the startup operation's returned promise, explicit cancellation signal, and SDK-host context. The existing browser assertions remain unchanged.
Evidence
c881d464aafe(50.50s), fails with 503 on7d18cafe121a, and passes with this fix (48.65s Vitest; 99s including preparation). The reported good/bad heads and fresh main independently reproduce the same boundary.66c4c328ea0bafter a real build (100s build, 80s test command); the runtime receipt records that exact head andinputsClean=true. No assertion or publication guard was changed.608134ea54c3: Madge reports the existing prepared-model-catalog-fingerprints/worker cycle; Knip reports four existing unused exports. Every unreached tail check was run separately and passed. No ignores or suppressions were added.The Knip findings are
bindCliQuestionAnswerAuthority,prepareSessionEventTargetForHost,readSessionEntryCreationTransition, andRESTART_CONTINUATION_CONTEXT_PREFIX; the last two also appear in the all-exports scan.This is a Gateway lifecycle fix; UI appearance is unchanged. The existing headless browser flow supplies the HTTP and login-handoff regression proof. Full Gateway configurations were not rerun; proof covers the affected owners and the original real-Gateway shard.