mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 09:01:39 -06:00
c557246437
* fix(watch): defer restart when dist/ is mid-rebuild (#99603) Defer gateway:watch child restart when run-node's build/runtime-postbuild readiness contract reports a hard dist/ failure. Only defers on conditions where the child physically cannot start, preserving normal restart behavior for soft staleness that run-node can rebuild on start. Hard failures (defer restart): - missing_dist_entry (mid-rebuild) - missing_bundled_plugin_dist_entry - missing_private_qa_dist - missing_runtime_postbuild_output Soft staleness (allow restart, run-node rebuilds): - missing_build_stamp (w/ direct entry.js check for masked case) - git_head_changed, dirty_watched_tree - config_newer, build_stamp_missing_head, source_mtime_newer isBuildReadyForRestart delegates to resolveBuildRequirement and resolveRuntimePostBuildRequirement from run-node.mjs, using the watcher process environment for consistency with the child runner. 200ms polling with 5-min timeout. Child-exit bounded recovery. Clears stale restartRequested on timeout/poll errors. Ref: #99603 Co-Authored-By: Claude <noreply@anthropic.com> * fix(watch): deduplicate deferral loops, add single-flight guard, remove lint suppression - Extract deferUntilBuildReady(onReady, onTimeout) shared helper, replacing the near-identical pollBuildReady and pollAfterChildExit. - Add single-flight guard (deferredRestartActive) so concurrent file change events during deferral coalesce into one poll loop instead of spawning a git-subprocess storm. - Replace inline .catch arrow callback with method-style call, removing the oxlint-disable-next-line suppression and its allowlist entry. - Add tests: coalescing multiple changes, requestRestart recovery. Ref: #99603 Co-Authored-By: Claude <noreply@anthropic.com> * fix: keep gateway watch alive during concurrent builds --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Peter Steinberger <steipete@gmail.com>
22 lines
801 B
TypeScript
22 lines
801 B
TypeScript
// Type declarations for repo scripts imported by tests without publishing them
|
|
// as normal TypeScript modules.
|
|
declare module "../../scripts/watch-node.mjs" {
|
|
export function resolveWatchLockPath(cwd: string, args?: string[]): string;
|
|
export function runWatchMain(params?: {
|
|
spawn?: (
|
|
cmd: string,
|
|
args: string[],
|
|
options: unknown,
|
|
) => { on: (event: "exit", cb: (code: number | null, signal: string | null) => void) => void };
|
|
process?: NodeJS.Process;
|
|
cwd?: string;
|
|
args?: string[];
|
|
env?: NodeJS.ProcessEnv;
|
|
fs?: { existsSync: (path: string) => boolean };
|
|
now?: () => number;
|
|
sleep?: (ms: number) => Promise<void>;
|
|
signalProcess?: (pid: number, signal: NodeJS.Signals | 0) => void;
|
|
lockDisabled?: boolean;
|
|
}): Promise<number>;
|
|
}
|