File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
93102describe ( "manual cron route-lease lifecycle — issue #92460 P1 manual path" , ( ) => {
You can’t perform that action at this time.
0 commit comments