@@ -102,7 +102,15 @@ export class TranscriberContainer extends Container {
102102 }
103103
104104 override onError ( error : unknown ) {
105- console . error ( 'Transcriber container error:' , error ) ;
105+ // Properly serialize error for Cloudflare Workers logging
106+ if ( error instanceof Error ) {
107+ console . error ( 'Transcriber container error:' , error . message , error . stack ) ;
108+ } else if ( typeof error === 'string' ) {
109+ console . error ( 'Transcriber container error:' , error ) ;
110+ } else {
111+ // For other types (Date, objects, etc.), stringify them
112+ console . error ( 'Transcriber container error:' , JSON . stringify ( error ) ) ;
113+ }
106114 }
107115}
108116
@@ -246,15 +254,19 @@ async function handleWebSocketWithDispatcher(
246254 . dispatch ( dispatcherMessage )
247255 . then ( ( response ) => {
248256 if ( ! response . success || response . errors ) {
249- console . error ( 'Dispatcher error:' , {
250- message : response . message ,
251- errors : response . errors ,
252- } ) ;
257+ console . error (
258+ 'Dispatcher error:' ,
259+ JSON . stringify ( {
260+ message : response . message ,
261+ errors : response . errors ,
262+ } ) ,
263+ ) ;
253264 }
254265 } )
255266 . catch ( ( error ) => {
256267 const msg = error instanceof Error ? error . message : String ( error ) ;
257- console . error ( 'Dispatcher RPC failed:' , msg ) ;
268+ const stack = error instanceof Error ? error . stack : undefined ;
269+ console . error ( 'Dispatcher RPC failed:' , msg , stack || '' ) ;
258270 } ) ;
259271 }
260272 } catch {
@@ -350,7 +362,9 @@ export default {
350362 body : JSON . stringify ( { sessionId, containerId : containerInstanceId } ) ,
351363 } )
352364 . catch ( ( error ) => {
353- console . error ( 'Failed to report connection opened:' , error ) ;
365+ const msg = error instanceof Error ? error . message : JSON . stringify ( error ) ;
366+ const stack = error instanceof Error ? error . stack : undefined ;
367+ console . error ( 'Failed to report connection opened:' , msg , stack || '' ) ;
354368 } ) ,
355369 ) ;
356370 }
0 commit comments