mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-04-30 22:12:32 +08:00
fix(update): keep downgrade follow-ups in-process
This commit is contained in:
@@ -479,6 +479,31 @@ describe("update-cli", () => {
|
||||
expect(runDaemonRestart).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps downgrade post-update work in the current process", async () => {
|
||||
setupUpdatedRootRefresh({
|
||||
gatewayUpdateImpl: async () =>
|
||||
makeOkUpdateResult({
|
||||
mode: "npm",
|
||||
root: createCaseDir("openclaw-downgraded-root"),
|
||||
before: { version: "2026.4.14" },
|
||||
after: { version: "2026.4.10" },
|
||||
}),
|
||||
});
|
||||
readPackageVersion.mockResolvedValue("2026.4.14");
|
||||
vi.mocked(resolveNpmChannelTag).mockResolvedValue({
|
||||
tag: "latest",
|
||||
version: "2026.4.10",
|
||||
});
|
||||
|
||||
await updateCommand({ yes: true, tag: "2026.4.10" });
|
||||
|
||||
expect(spawn).not.toHaveBeenCalled();
|
||||
expect(syncPluginsForUpdateChannel).toHaveBeenCalled();
|
||||
expect(updateNpmInstalledPlugins).toHaveBeenCalled();
|
||||
expect(runDaemonInstall).toHaveBeenCalled();
|
||||
expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it("fails the update when the fresh process exits non-zero", async () => {
|
||||
setupUpdatedRootRefresh();
|
||||
spawn.mockImplementationOnce(() => {
|
||||
|
||||
@@ -814,6 +814,13 @@ async function continuePostCoreUpdateInFreshProcess(params: {
|
||||
return true;
|
||||
}
|
||||
|
||||
function shouldResumePostCoreUpdateInFreshProcess(params: {
|
||||
result: UpdateRunResult;
|
||||
downgradeRisk: boolean;
|
||||
}): boolean {
|
||||
return isPackageManagerUpdateMode(params.result.mode) && !params.downgradeRisk;
|
||||
}
|
||||
|
||||
export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
|
||||
suppressDeprecations();
|
||||
const invocationCwd = tryResolveInvocationCwd();
|
||||
@@ -1149,7 +1156,12 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
|
||||
const postUpdateRoot = result.root ?? root;
|
||||
|
||||
let pluginsUpdatedInFreshProcess = false;
|
||||
if (isPackageManagerUpdateMode(result.mode)) {
|
||||
if (
|
||||
shouldResumePostCoreUpdateInFreshProcess({
|
||||
result,
|
||||
downgradeRisk,
|
||||
})
|
||||
) {
|
||||
pluginsUpdatedInFreshProcess = await continuePostCoreUpdateInFreshProcess({
|
||||
root: postUpdateRoot,
|
||||
channel,
|
||||
|
||||
Reference in New Issue
Block a user