File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,13 @@ export class ExtensionMetadataService {
9191 const content = JSON . stringify ( data , null , 2 ) ;
9292 await writeFileAtomic ( this . filePath , content , "utf-8" ) ;
9393 } catch ( error ) {
94+ const err = error as NodeJS . ErrnoException ;
95+ // In Jest/browser harness runs we frequently use a temporary config dir that can be
96+ // deleted as soon as a test finishes. Ignore ENOENT to avoid noisy "Cannot log after
97+ // tests are done" warnings.
98+ if ( process . env . NODE_ENV === "test" && err . code === "ENOENT" ) {
99+ return ;
100+ }
94101 log . error ( "Failed to save metadata:" , error ) ;
95102 }
96103 }
Original file line number Diff line number Diff line change @@ -169,17 +169,19 @@ export class AgentSession {
169169 if ( this . disposed ) {
170170 return ;
171171 }
172+ // Detach listeners first so stopStream() can't emit events into a disposed session.
173+ for ( const { event, handler } of this . aiListeners ) {
174+ this . aiService . off ( event , handler as never ) ;
175+ }
176+ this . aiListeners . length = 0 ;
177+
172178 this . disposed = true ;
173179
174180 // Stop any active stream (fire and forget - disposal shouldn't block)
175181 void this . aiService . stopStream ( this . workspaceId , { abandonPartial : true } ) ;
176182 // Terminate background processes for this workspace
177183 void this . backgroundProcessManager . cleanup ( this . workspaceId ) ;
178184
179- for ( const { event, handler } of this . aiListeners ) {
180- this . aiService . off ( event , handler as never ) ;
181- }
182- this . aiListeners . length = 0 ;
183185 for ( const { event, handler } of this . initListeners ) {
184186 this . initStateManager . off ( event , handler as never ) ;
185187 }
You can’t perform that action at this time.
0 commit comments