mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
This commit is contained in:
parent
818a9c7be0
commit
d4d3d6cda5
1 changed files with 17 additions and 17 deletions
|
|
@ -16,6 +16,7 @@ import {
|
|||
} from "../../plugins/memory-runtime.js";
|
||||
import { resetStandaloneMemoryRegistrySlot } from "../../plugins/memory-runtime.test-support.js";
|
||||
import {
|
||||
closeOpenClawAgentDatabasesAsync,
|
||||
closeOpenClawAgentDatabasesForTest,
|
||||
openOpenClawAgentDatabase,
|
||||
} from "../../state/openclaw-agent-db.js";
|
||||
|
|
@ -32,27 +33,25 @@ const checkpoint = vi.hoisted(() => ({
|
|||
authorizations: [] as Promise<void>[],
|
||||
}));
|
||||
|
||||
vi.mock("./session-accessor.sqlite-archive.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./session-accessor.sqlite-archive.js")>();
|
||||
vi.mock("./session-accessor.sqlite-worker-request.js", async (importOriginal) => {
|
||||
const actual =
|
||||
await importOriginal<typeof import("./session-accessor.sqlite-worker-request.js")>();
|
||||
return {
|
||||
...actual,
|
||||
runSqliteTranscriptArchiveWorkerOperation: (
|
||||
params: Parameters<typeof actual.runSqliteTranscriptArchiveWorkerOperation>[0],
|
||||
runSqliteMutationWorkerRequest: <Result>(
|
||||
params: Parameters<typeof actual.runSqliteMutationWorkerRequest<Result>>[0],
|
||||
) =>
|
||||
actual.runSqliteTranscriptArchiveWorkerOperation({
|
||||
actual.runSqliteMutationWorkerRequest({
|
||||
...params,
|
||||
onCommitRequest: params.onCommitRequest
|
||||
? () => {
|
||||
checkpoint.startForeground?.();
|
||||
// Let prepared foreground continuations run before the queued parent
|
||||
// authorizer, while the actual reclamation Worker holds its writer lock.
|
||||
const authorization = setImmediate().then(() => {
|
||||
params.onCommitRequest?.();
|
||||
});
|
||||
checkpoint.authorizations.push(authorization);
|
||||
void authorization.catch(() => {});
|
||||
}
|
||||
: undefined,
|
||||
onCommitRequest: () => {
|
||||
checkpoint.startForeground?.();
|
||||
// Let foreground continuations run while the reclamation Worker holds its writer lock.
|
||||
const authorization = setImmediate().then(() => {
|
||||
params.onCommitRequest();
|
||||
});
|
||||
checkpoint.authorizations.push(authorization);
|
||||
void authorization.catch(() => {});
|
||||
},
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
|
@ -86,6 +85,7 @@ describe("reclamation with the public memory runtime", () => {
|
|||
await closeActiveMemorySearchManagersCore();
|
||||
resetStandaloneMemoryRegistrySlot();
|
||||
clearPluginLoaderCache();
|
||||
await closeOpenClawAgentDatabasesAsync();
|
||||
closeOpenClawAgentDatabasesForTest();
|
||||
resetPluginStateStoreForTests();
|
||||
closeOpenClawStateDatabaseForTest();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue