Skip to content

fix(gateway): avoid sync restart sentinel startup probes#80371

Merged
steipete merged 1 commit into
mainfrom
fix/async-restart-sentinel-startup-gate
May 10, 2026
Merged

fix(gateway): avoid sync restart sentinel startup probes#80371
steipete merged 1 commit into
mainfrom
fix/async-restart-sentinel-startup-gate

Conversation

@steipete

@steipete steipete commented May 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Real behavior proof

  • Behavior or issue addressed: gateway post-attach restart-sentinel presence checks no longer synchronously probe the configured state directory, so slow Windows or redirected state dirs cannot block the event loop on this path.
  • Real environment tested: local OpenClaw checkout on macOS, Node 26.0.0, with a real temporary OPENCLAW_STATE_DIR containing restart-sentinel.json.
  • Exact steps or command run after this patch: ran a live node --import tsx command that monkey-patched fs.existsSync to throw for the configured state path, imported the gateway startup module, and called the restart-sentinel presence check against the real temp state directory.
  • Evidence after fix:
$ OPENCLAW_STATE_DIR="$tmp" node --import tsx --input-type=module - <<'EOF'
import fs from "node:fs";
const actualExistsSync = fs.existsSync;
fs.existsSync = (candidate) => {
  if (String(candidate).startsWith(process.env.OPENCLAW_STATE_DIR ?? "")) {
    throw new Error("sync restart-sentinel state probe used");
  }
  return actualExistsSync(candidate);
};
const { __testing } = await import("./src/gateway/server-startup-post-attach.ts");
const present = await __testing.hasRestartSentinelFileFast({
  OPENCLAW_STATE_DIR: process.env.OPENCLAW_STATE_DIR,
});
console.log(JSON.stringify({ restartSentinelPresent: present, syncStateProbe: "not called" }));
EOF
{"restartSentinelPresent":true,"syncStateProbe":"not called"}
  • Observed result after fix: the real temp restart sentinel was detected and the injected synchronous state-path probe trap was not hit.
  • What was not tested: Windows redirected-home latency was not reproduced directly; this proof verifies the blocking sync filesystem call is gone from the implicated startup path.

Verification

  • pnpm test src/gateway/server-startup-post-attach.test.ts
  • env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_REMOTE_RUN -u OPENCLAW_TESTBOX_ID pnpm check:changed
  • git diff --check origin/main...HEAD

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(gateway): avoid sync restart sentinel startup probes This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete
steipete merged commit 3a05c71 into main May 10, 2026
120 of 126 checks passed
@steipete
steipete deleted the fix/async-restart-sentinel-startup-gate branch May 10, 2026 18:07
@steipete

Copy link
Copy Markdown
Contributor Author

Landed via rebase onto main.

  • Gate: PR CI green, Real behavior proof green; local pnpm test src/gateway/server-startup-post-attach.test.ts; local env -u OPENCLAW_TESTBOX -u OPENCLAW_TESTBOX_REMOTE_RUN -u OPENCLAW_TESTBOX_ID pnpm check:changed
  • Land commit: 3a05c71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Regression] post-attach.update-sentinel ~9s sync block per model_call (previously 0ms) — v2026.5.7

1 participant