





















@@ -21,10 +21,18 @@ import { GATEWAY_SERVICE_RUNTIME_PID_ENV } from "../daemon/constants.js";
2121import { resolveGatewayInstallEntrypoint } from "../daemon/gateway-entrypoint.js";
2222import { runCommandWithTimeout } from "../process/exec.js";
2323import { resolveStableNodePath } from "./stable-node-path.js";
24-import type { UpdateChannel } from "./update-channels.js";
24+import { DEFAULT_GIT_CHANNEL, type UpdateChannel } from "./update-channels.js";
2525import type { UpdateRunResult } from "./update-runner.js";
262627-const DEFAULT_FINALIZE_TIMEOUT_MS = 30 * 60_000;
27+// Whole-process backstop for the finalizer. `update finalize` runs several timed
28+// steps (doctor + plugin update/convergence), each bounded by its own per-step
29+// `--timeout`. The outer process kill must therefore be larger than a single
30+// per-step bound, or a valid multi-step run would be killed and falsely reported
31+// as `post-core-plugin-finalize-failed` (blocking the restart). We use a generous
32+// floor and, when a larger per-step timeout is requested, scale the outer bound
33+// above it rather than reusing the per-step value as the whole-process kill.
34+const FINALIZE_PROCESS_TIMEOUT_FLOOR_MS = 30 * 60_000;
35+const FINALIZE_PROCESS_STEP_BUDGET_MULTIPLIER = 6;
28362937// Strip the running gateway's service identity from the finalizer child so it is
3038// not mistaken for the managed service process (matches the CLI post-core spawn).
@@ -146,27 +154,37 @@ export async function runPostCoreFinalizeAfterGatewayUpdate(params: {
146154}
147155148156const spawnFinalize = params.spawnFinalize ?? defaultFinalizeSpawner;
149-const timeoutMs =
157+const perStepTimeoutMs =
150158typeof params.timeoutMs === "number" && Number.isFinite(params.timeoutMs)
151159 ? params.timeoutMs
152160 : undefined;
161+// This helper only runs for git/source updates, where `runGatewayUpdate`
162+// defaults the core update to the git/dev channel (`opts.channel ?? "dev"`).
163+// Match it so the finalizer converges official plugins on the same channel as
164+// the core update instead of falling back to the package (stable) channel.
165+const channel = params.channel ?? DEFAULT_GIT_CHANNEL;
153166const nodePath = await resolveStableNodePath(process.execPath);
154167const argv = buildFinalizeArgv({
155168 nodePath,
156169 entrypoint,
157-...(params.channel ? { channel: params.channel } : {}),
158- ...(timeoutMs === undefined ? {} : { timeoutMs }),
170+ channel,
171+ ...(perStepTimeoutMs === undefined ? {} : { timeoutMs: perStepTimeoutMs }),
159172});
160173// Pin the finalizer's host-compat resolution to the just-installed core
161174// version so plugins reconcile against the new core, not the running process.
162175const compatHostVersion = result.after?.version ?? undefined;
163176const env = buildFinalizeEnv(params.env ?? process.env, compatHostVersion);
177+// Outer whole-process backstop, decoupled from the per-step `--timeout` above.
178+const processTimeoutMs = Math.max(
179+FINALIZE_PROCESS_TIMEOUT_FLOOR_MS,
180+(perStepTimeoutMs ?? 0) * FINALIZE_PROCESS_STEP_BUDGET_MULTIPLIER,
181+);
164182165183try {
166184const spawnResult = await spawnFinalize({
167185 argv,
168186cwd: path.dirname(entrypoint),
169-timeoutMs: timeoutMs ?? DEFAULT_FINALIZE_TIMEOUT_MS,
187+timeoutMs: processTimeoutMs,
170188 env,
171189});
172190if (spawnResult.code === 0) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。