Skip to content

Commit 6a7164f

Browse files
test(cron): move manual lease reset/close under temp state env for #92460
1 parent 4512fd4 commit 6a7164f

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/cron/service/ops.issue-92460-manual-lease.test.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,26 @@ async function withStateDirForStorePath<T>(
7777
runWithStateDir: () => Promise<T>,
7878
): Promise<T> {
7979
const stateRoot = path.dirname(path.dirname(storePath));
80-
resetTaskRouteLeasesForTests();
81-
try {
82-
return await withEnvAsync({ OPENCLAW_STATE_DIR: stateRoot }, runWithStateDir);
83-
} finally {
80+
// Issue #92460 (ClawSweeper 4th round P2): resetTaskRouteLeasesForTests
81+
// and closeOpenClawStateDatabaseForTest must run INSIDE the
82+
// withEnvAsync scope so they operate on the temp OPENCLAW_STATE_DIR
83+
// fixture, not the developer's default shared state DB. Previously
84+
// the outer reset ran before withEnvAsync installed the temp env, and
85+
// the finally reset ran after withEnvAsync restored the previous
86+
// env, so both could touch the default DB.
87+
return await withEnvAsync({ OPENCLAW_STATE_DIR: stateRoot }, async () => {
8488
resetTaskRouteLeasesForTests();
8589
try {
86-
closeOpenClawStateDatabaseForTest();
87-
} catch {
88-
// noop
90+
return await runWithStateDir();
91+
} finally {
92+
resetTaskRouteLeasesForTests();
93+
try {
94+
closeOpenClawStateDatabaseForTest();
95+
} catch {
96+
// noop
97+
}
8998
}
90-
}
99+
});
91100
}
92101

93102
describe("manual cron route-lease lifecycle — issue #92460 P1 manual path", () => {

0 commit comments

Comments
 (0)