File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ export class SSEOutputAdapter implements IUserInterface {
301301 if ( ! success ) {
302302 this . logger . warn ( `Failed to emit event ${ event . type } for job ${ this . jobId } ` )
303303 console . log ( `[SSE] Failed to send event ${ event . type } for job ${ this . jobId } ` )
304- console . log ( `[SSE] Available streams:` , Object . keys ( ( this . streamManager as any ) . streams || { } ) )
304+ console . log ( `[SSE] Available streams:` , this . streamManager . getActiveStreamIds ( ) )
305305 } else {
306306 console . log ( `[SSE] Successfully sent event ${ event . type } for job ${ this . jobId } ` )
307307 }
Original file line number Diff line number Diff line change @@ -300,4 +300,27 @@ describe("SSEOutputAdapter", () => {
300300 expect ( new Date ( event . timestamp ) ) . toBeInstanceOf ( Date )
301301 } )
302302 } )
303+
304+ describe ( "error handling" , ( ) => {
305+ it ( "should handle stream failure gracefully" , async ( ) => {
306+ // Close the stream to simulate failure
307+ streamManager . closeStream ( jobId )
308+
309+ // Spy on console.log to verify error logging
310+ const consoleSpy = jest . spyOn ( console , "log" ) . mockImplementation ( ( ) => { } )
311+
312+ await adapter . showInformation ( "Test message" )
313+
314+ // Verify that error logging uses public API
315+ expect ( consoleSpy ) . toHaveBeenCalledWith (
316+ expect . stringContaining ( "[SSE] Failed to send event information for job test-job-123" ) ,
317+ )
318+ expect ( consoleSpy ) . toHaveBeenCalledWith (
319+ expect . stringContaining ( "[SSE] Available streams:" ) ,
320+ expect . any ( Array ) ,
321+ )
322+
323+ consoleSpy . mockRestore ( )
324+ } )
325+ } )
303326} )
Original file line number Diff line number Diff line change 44 */
55
66import * as os from "os"
7+ import * as path from "path"
78
89/**
910 * Get the global storage path for the application
1011 * Uses .agentz directory for consistency with CLI config
1112 */
1213export function getGlobalStoragePath ( ) : string {
1314 const homeDir = os . homedir ( )
14- return ` ${ homeDir } / .agentz`
15+ return path . join ( homeDir , " .agentz" )
1516}
1617
1718/**
1819 * Get the fallback storage path for environments without home directory
1920 */
2021export function getFallbackStoragePath ( ) : string {
21- return "/tmp/ .agentz"
22+ return path . join ( "/tmp" , " .agentz")
2223}
2324
2425/**
You can’t perform that action at this time.
0 commit comments