Skip to content

Commit 6f92f1b

Browse files
authored
Fix missing log messages. (#46)
1 parent 1ac761b commit 6f92f1b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

worker/ContainerCoordinator.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ export class ContainerCoordinator extends DurableObject {
286286
return new Response('Not Found', { status: 404 });
287287
}
288288
} catch (error) {
289-
console.error('Coordinator error:', error);
289+
// Properly serialize error for Cloudflare Workers logging
290+
const errorMessage = error instanceof Error ? error.message : JSON.stringify(error);
291+
const errorStack = error instanceof Error ? error.stack : undefined;
292+
console.error('Coordinator error:', errorMessage, errorStack || '');
290293
return Response.json(
291294
{
292295
error: error instanceof Error ? error.message : String(error),

worker/index.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)