mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:10:45 +00:00
fix(cli): ignore stale memory cleanup after package update
This commit is contained in:
@@ -545,6 +545,17 @@ describe("runCli exit behavior", () => {
|
|||||||
expect(closeActiveMemorySearchManagersMock).toHaveBeenCalledTimes(1);
|
expect(closeActiveMemorySearchManagersMock).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not fail the command when memory cleanup is unavailable", async () => {
|
||||||
|
tryRouteCliMock.mockResolvedValueOnce(true);
|
||||||
|
hasMemoryRuntimeMock.mockImplementationOnce(() => {
|
||||||
|
throw new Error("stale memory-state chunk");
|
||||||
|
});
|
||||||
|
|
||||||
|
await expect(runCli(["node", "openclaw", "status"])).resolves.toBeUndefined();
|
||||||
|
|
||||||
|
expect(closeActiveMemorySearchManagersMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it("returns after a handled container-target invocation", async () => {
|
it("returns after a handled container-target invocation", async () => {
|
||||||
maybeRunCliInContainerMock.mockReturnValueOnce({ handled: true, exitCode: 0 });
|
maybeRunCliInContainerMock.mockReturnValueOnce({ handled: true, exitCode: 0 });
|
||||||
|
|
||||||
|
|||||||
@@ -191,15 +191,16 @@ async function tryRunGatewayRunFastPath(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function closeCliMemoryManagers(): Promise<void> {
|
async function closeCliMemoryManagers(): Promise<void> {
|
||||||
const { hasMemoryRuntime } = await import("../plugins/memory-state.js");
|
|
||||||
if (!hasMemoryRuntime()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
const { hasMemoryRuntime } = await import("../plugins/memory-state.js");
|
||||||
|
if (!hasMemoryRuntime()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { closeActiveMemorySearchManagers } = await import("../plugins/memory-runtime.js");
|
const { closeActiveMemorySearchManagers } = await import("../plugins/memory-runtime.js");
|
||||||
await closeActiveMemorySearchManagers();
|
await closeActiveMemorySearchManagers();
|
||||||
} catch {
|
} catch {
|
||||||
// Best-effort teardown for short-lived CLI processes.
|
// Best-effort teardown for short-lived CLI processes. Package updates can
|
||||||
|
// replace hashed chunks before this finalizer runs.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user