fix: enable sync io tracing in gateway watch

This commit is contained in:
Peter Steinberger
2026-05-04 22:44:19 +01:00
parent e84d4b27f4
commit 35e48a049b
3 changed files with 37 additions and 0 deletions

View File

@@ -96,6 +96,10 @@ add Node's sync I/O trace flag through the source runner:
OPENCLAW_TRACE_SYNC_IO=1 pnpm openclaw gateway --force
```
`pnpm gateway:watch` enables this flag by default for the watched Gateway child.
Set `OPENCLAW_TRACE_SYNC_IO=0` to suppress Node sync I/O trace output in watch
mode.
## Gateway watch mode
For fast iteration, run the gateway under the file watcher:

View File

@@ -277,6 +277,9 @@ export async function runWatchMain(params = {}) {
// The watcher owns process restarts; keep SIGUSR1/config reloads in-process
// so inherited launchd/systemd markers do not make the child exit and stall.
childEnv.OPENCLAW_NO_RESPAWN = "1";
if (isGatewayWatchCommand(deps.args) && childEnv.OPENCLAW_TRACE_SYNC_IO === undefined) {
childEnv.OPENCLAW_TRACE_SYNC_IO = "1";
}
if (deps.args.length > 0) {
childEnv.OPENCLAW_WATCH_COMMAND = deps.args.join(" ");
}

View File

@@ -143,6 +143,7 @@ describe("watch-node script", () => {
OPENCLAW_WATCH_MODE: "1",
OPENCLAW_WATCH_SESSION: "1700000000000-4242",
OPENCLAW_NO_RESPAWN: "1",
OPENCLAW_TRACE_SYNC_IO: "1",
OPENCLAW_WATCH_COMMAND: "gateway --force",
}),
}),
@@ -155,6 +156,35 @@ describe("watch-node script", () => {
});
});
it("preserves explicit sync I/O trace overrides for gateway watch", async () => {
const { child, spawn, createWatcher, fakeProcess } = createWatchHarness();
await withTempDir({ prefix: "openclaw-watch-node-" }, async (cwd) => {
const runPromise = runWatch({
args: ["gateway", "--force"],
cwd,
createWatcher,
env: { OPENCLAW_TRACE_SYNC_IO: "0" },
lockDisabled: true,
process: fakeProcess,
spawn,
});
expect(spawn).toHaveBeenCalledWith(
"/usr/local/bin/node",
["scripts/run-node.mjs", "gateway", "--force"],
expect.objectContaining({
env: expect.objectContaining({
OPENCLAW_TRACE_SYNC_IO: "0",
}),
}),
);
fakeProcess.emit("SIGINT");
await runPromise;
expect(child.kill).toHaveBeenCalledWith("SIGTERM");
});
});
it("starts the runner before loading chokidar", async () => {
const child = Object.assign(new EventEmitter(), {
kill: vi.fn(() => {}),