Repository navigation
fix(gateway): unbreak cloud session creation — stale chat metadata, unbounded tunnel hangs, swallowed dispatch errors - #120926
Merged
Conversation
steipete
marked this pull request as ready for review
August 9, 2026 05:38
chat.metadata cached a prepared generation built before the runtime auth-profile store snapshot was published (empty-store fallback) and generationFactsMatch never compared auth state, so the Control UI showed "No models available" after a gateway restart until an unrelated config edit. Capture per-agent auth snapshot revisions in the generation facts, subscribe the metadata lifecycle to auth-store mutations, and run one awaited revision-aware catch-up refresh after listener registration so publications that precede registration are still observed.
…failure detail Live stress-testing the Control UI cloud flow found sessions.dispatch hanging unbounded (observed 12+ min) when the worker SSH tunnel could not connect: the runner's exited promise settled only on "close" (a spawn error never settled it), the reconnect loop swallowed every failure with no logging, the poisoned ready promise was re-handed to every later dispatch, and dispatch errors dropped the actionable reason recorded in worker_environments.last_error. - settle exited on the real "exit" event, wire the owner abort signal into spawn, bound stop()'s post-SIGKILL wait, and fail stop honestly when termination is unconfirmed instead of fabricating an exit - add a 60s per-attempt readiness deadline and log each failed connect attempt (bounded, redacted); keep an unconfirmed child tracked and wait for its real exit before retrying - add a 3-minute epoch-fenced startTunnel deadline with a typed, actionable error; detach its cleanup so the deadline holds - append the bounded recorded reason to the five dispatch-visible worker environment error messages (docs already promise these) - remote socket setup: drop "--" from chmod (BSD/macOS chmod treats it as a filename), which blocked every tunnel to a macOS worker host - workspace quiescence: tolerate EPERM without crashing the protocol while keeping unsignalable freeze targets counted as live so quiescence fails closed
steipete
force-pushed
the
steipete/cloud-feature-stress-test-41089b
branch
from
August 9, 2026 05:46
911272d to
48385ff
Compare
Contributor
Author
|
Merged via squash.
|
This was referenced Aug 9, 2026
This was referenced Aug 9, 2026
steipete
added a commit
that referenced
this pull request
Aug 9, 2026
A gateway startup stall (#120926, awaited chat-metadata refresh in minimal mode) shipped with green CI and first surfaced by hanging every checks-ui-e2e suite that boots a minimal test gateway: no gateway-lane test booted one with bundled plugins enabled (gateway.test.ts disables them, which masked the stall), and the changed-scope classifier only selects the ui-e2e lane for ui-touching diffs. Add a minimal-gateway boot smoke in src/gateway that mirrors the ui-e2e boot environment (bundled plugins enabled, minimal skips, strict time budget). Selection is automatic: the smoke imports the gateway server, so the changed node test plan picks it up through the import graph for any diff that can affect startup, and full-suite plans run it in the agentic-control-plane-startup-core shard. Reintroducing the #120926 hunk makes the smoke fail (watchdog kill) in the gateway lane; healthy code boots in ~10s. A planner regression test keeps the smoke classified as a gateway-server test file and import-graph-reachable from gateway startup sources, so a rename or graph-invisible import shape cannot silently drop the coverage again.
steipete
added a commit
that referenced
this pull request
Aug 9, 2026
* test(gateway): boot a minimal test gateway in the gateway lane A gateway startup stall (#120926, awaited chat-metadata refresh in minimal mode) shipped with green CI and first surfaced by hanging every checks-ui-e2e suite that boots a minimal test gateway: no gateway-lane test booted one with bundled plugins enabled (gateway.test.ts disables them, which masked the stall), and the changed-scope classifier only selects the ui-e2e lane for ui-touching diffs. Add a minimal-gateway boot smoke in src/gateway that mirrors the ui-e2e boot environment (bundled plugins enabled, minimal skips, strict time budget). Selection is automatic: the smoke imports the gateway server, so the changed node test plan picks it up through the import graph for any diff that can affect startup, and full-suite plans run it in the agentic-control-plane-startup-core shard. Reintroducing the #120926 hunk makes the smoke fail (watchdog kill) in the gateway lane; healthy code boots in ~10s. A planner regression test keeps the smoke classified as a gateway-server test file and import-graph-reachable from gateway startup sources, so a rename or graph-invisible import shape cannot silently drop the coverage again. * test(ui): resolve labs rows by registry id, not positional index Unblocks landing onto red main: 8fdf757 (#120727) added the Cloud Worker Desktop labs entry with a hardcoded row index that collides with Message audit metadata, so enabling it toggled the neighboring row and the full-suite lane failed deterministically (labs-page.test.ts, exposed only on PRs that run the compact full suite). Derive each table case's row index from LAB_FEATURES by feature id — the idiom the rest of the suite already uses — so a new labs entry can no longer silently retarget an existing case.
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 10, 2026
…nbounded tunnel hangs, swallowed dispatch errors (openclaw#120926) * fix(gateway): rebuild chat metadata when auth-profile snapshots change chat.metadata cached a prepared generation built before the runtime auth-profile store snapshot was published (empty-store fallback) and generationFactsMatch never compared auth state, so the Control UI showed "No models available" after a gateway restart until an unrelated config edit. Capture per-agent auth snapshot revisions in the generation facts, subscribe the metadata lifecycle to auth-store mutations, and run one awaited revision-aware catch-up refresh after listener registration so publications that precede registration are still observed. * fix(gateway): bound cloud worker tunnel startup and surface dispatch failure detail Live stress-testing the Control UI cloud flow found sessions.dispatch hanging unbounded (observed 12+ min) when the worker SSH tunnel could not connect: the runner's exited promise settled only on "close" (a spawn error never settled it), the reconnect loop swallowed every failure with no logging, the poisoned ready promise was re-handed to every later dispatch, and dispatch errors dropped the actionable reason recorded in worker_environments.last_error. - settle exited on the real "exit" event, wire the owner abort signal into spawn, bound stop()'s post-SIGKILL wait, and fail stop honestly when termination is unconfirmed instead of fabricating an exit - add a 60s per-attempt readiness deadline and log each failed connect attempt (bounded, redacted); keep an unconfirmed child tracked and wait for its real exit before retrying - add a 3-minute epoch-fenced startTunnel deadline with a typed, actionable error; detach its cleanup so the deadline holds - append the bounded recorded reason to the five dispatch-visible worker environment error messages (docs already promise these) - remote socket setup: drop "--" from chmod (BSD/macOS chmod treats it as a filename), which blocked every tunnel to a macOS worker host - workspace quiescence: tolerate EPERM without crashing the protocol while keeping unsignalable freeze targets counted as live so quiescence fails closed * test(gateway): type worker child kill mock
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 10, 2026
…law#121134) * test(gateway): boot a minimal test gateway in the gateway lane A gateway startup stall (openclaw#120926, awaited chat-metadata refresh in minimal mode) shipped with green CI and first surfaced by hanging every checks-ui-e2e suite that boots a minimal test gateway: no gateway-lane test booted one with bundled plugins enabled (gateway.test.ts disables them, which masked the stall), and the changed-scope classifier only selects the ui-e2e lane for ui-touching diffs. Add a minimal-gateway boot smoke in src/gateway that mirrors the ui-e2e boot environment (bundled plugins enabled, minimal skips, strict time budget). Selection is automatic: the smoke imports the gateway server, so the changed node test plan picks it up through the import graph for any diff that can affect startup, and full-suite plans run it in the agentic-control-plane-startup-core shard. Reintroducing the openclaw#120926 hunk makes the smoke fail (watchdog kill) in the gateway lane; healthy code boots in ~10s. A planner regression test keeps the smoke classified as a gateway-server test file and import-graph-reachable from gateway startup sources, so a rename or graph-invisible import shape cannot silently drop the coverage again. * test(ui): resolve labs rows by registry id, not positional index Unblocks landing onto red main: e675b67 (openclaw#120727) added the Cloud Worker Desktop labs entry with a hardcoded row index that collides with Message audit metadata, so enabling it toggled the neighboring row and the full-suite lane failed deterministically (labs-page.test.ts, exposed only on PRs that run the compact full suite). Derive each table case's row index from LAB_FEATURES by feature id — the idiom the rest of the suite already uses — so a new labs entry can no longer silently retarget an existing case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Live stress-testing the cloud-workers feature (Control UI → New Session → Cloud target, qa-lab
static-sshprovider against a real sshd, real dispatch/bootstrap) surfaced three severe, independently reproducible gateway bugs:chat.metadatabuilds its prepared generation while the runtime auth-profile store snapshot is not yet published, silently substituting an empty store, andgenerationFactsMatchnever compared auth-store state — so the wrong projection (every modelavailable: false) was cached until an unrelated config edit forced a rebuild. The Control UI new-session page and chat composer readchat.metadata, so the operator could not create any session (cloud or local) from any tab. Reproduced live:models.listsaidavailable: truewhilechat.metadatasaidfalsefor the same model, across restarts and fresh tabs.sessions.dispatchreturned bareWorker provider rejected profile/Worker bootstrap failedwhile the real cause (e.g.Worker bootstrap requires Node.js on the leased host; install Node in the provider setup phase and retry) was written only to theworker_environments.last_errorDB column. docs/gateway/cloud-workers.md's Troubleshooting section explicitly quotes those detailed messages as operator-visible, so shipped behavior contradicted the docs.sessions.dispatchhangs unbounded when the worker SSH tunnel cannot connect. Observed live: placement stuck insyncingfor 12+ minutes (returned only after a manualenvironments.destroy), UI spinner forever, leaked worker + placement, navigation unable to cancel. Mechanisms (traced and now regression-tested): the ssh child'sexitedpromise settles only onclose(a spawnerrornever settles it, parking the reconnect loop forever), no readiness deadline on the tunnel child or onstartTunnel, the abort signal was never wired intospawn, the poisonedentry.readypromise was re-handed to every later dispatch on the same owner epoch, and every connect failure was swallowed by a barecatch {}with no logger in the file.Why This Change Was Made
Cloud session creation is a default operator path; all three defects end in silent failure or an operator dead end (worst bug class per repo doctrine). Fixes are at the owning boundaries:
chat-metadata-runtime.ts: per-agent auth-store snapshot revision captured into generation facts and compared ingenerationFactsMatch;server-chat-metadata-lifecycle.tsadditionally subscribes to runtime auth-store mutations and performs one revision-aware catch-up refresh after listener registration (publications that precede registration were otherwise never observed).worker-environments/service.ts: the five dispatch-visible error messages now append the already-computedboundedWorkerErrordetail (redacted, 1 KiB cap) instead of discarding it.worker-environments/tunnel-ssh-runner.ts/tunnel.ts/service.ts:exitedsettles on spawnerrorand after a bounded post-SIGKILL wait; the owner abort signal is wired intospawn; each tunnel attempt has a 60s readiness deadline;startTunnelhas a 3-minute overall deadline that stops the tunnel entry and fails dispatch with a typed, actionable error; connect failures are logged (bounded) via agateway/worker-tunnelsubsystem logger.chmod 700 -- "$directory", and BSD/macOSchmodtreats--as a filename (chmod: --: No such file or directory), so every tunnel attempt to a Mac worker host fails and previously looped silently forever. Fixed by dropping the--(the path is script-owned and absolute);mkdir --/rm -f --are BSD-compatible and unchanged.User Impact
Evidence
sessions.dispatcherrors were bare (Worker provider rejected profile,Worker bootstrap failed) with the reason only inworker_environments.last_error; a tunnel-connect failure hung the dispatch RPC for732160ms(12.2 min) until a manualenvironments.destroy, with the UI spinning and the worker leaked; tunnel retries were completely silent.cloud startup failed: Worker tunnel did not connect within 3 minutes; check worker SSH reachability and retryat198790ms, the configured deadline); every tunnel attempt logsworker tunnel connect attempt failedwith the bounded ssh error — which immediately exposed the macOS chmod bug (chmod: --: No such file or directory). With that fixed, the full happy path completed:sessions.dispatchin12777ms, placementactive, environmentattached, first turn executed on the worker with the reply streamed to the Control UI.chat.metadataregression coverage reproduces the live staleness shape (generation built with an unavailable auth store stays cached; a published store with a bumped revision now rebuilds it).node scripts/run-vitest.mjs src/gateway/worker-environments/tunnel-ssh-runner.test.ts src/gateway/worker-environments/tunnel.test.ts src/gateway/worker-environments/service.test.ts src/gateway/server-methods/chat-metadata-runtime.test.ts→ 4 files, 109+ tests green (includes new regressions: auth-revision rebuild, retained-cache no-rebuild, provider-error detail in all five messages, spawn-error settlesexited, bounded post-SIGKILL stop, abort wiring, marker-less child timeout+retry,startTunneldeadline).node scripts/check-changed.mjs: typecheck core + core tests green; lint green after fixing an unbound-method finding in the new runner test.This PR also fixes a fifth bug found once reconciliation became reachable: the workspace quiescence script crashed mid-protocol on
kill EPERM(onlyESRCHwas tolerated), aborting reconcile with a raw stack instead of a diagnosable outcome. EPERM no longer crashes cleanup/resume paths; a freeze target that returns EPERM is un-marked so scans keep counting it as live and quiescence fails closed (a still-running unsignalable process is never reported as frozen — reviewer-hardened semantics).Follow-ups filed separately (found in the same stress run, out of scope here): startup publishes an empty runtime auth-store snapshot that nothing rehydrates until first inference (
models.listvschat.metadataavailability divergence); quiescence's uid-wide freeze cannot converge on shared static-ssh dev hosts; UI orphan-cleanup on transient describe failures;ownership-lostsilent dead end; terminalfailedplacement having no redispatch path; un-argumentedreconcileActiveafterenvironments.destroy; no "Stop cloud worker" menu item for asyncingplacement.