Fix: Append error messages to the chat stream

This commit is contained in:
2025-12-30 10:46:11 -08:00
parent 25a522c810
commit 798170a7db

View File

@@ -414,9 +414,11 @@ export class MyDurableObject {
fail(message) { fail(message) {
if (this.phase !== 'running') return; if (this.phase !== 'running') return;
const errStr = String(message || 'stream_failed');
this.queueDelta(`\n\nRun failed: ${errStr}`);
this.flush(true); this.flush(true);
this.phase = 'error'; this.phase = 'error';
this.error = String(message || 'stream_failed'); this.error = errStr;
try { this.controller?.abort(); } catch {} try { this.controller?.abort(); } catch {}
try { this.oaStream?.controller?.abort(); } catch {} try { this.oaStream?.controller?.abort(); } catch {}
this.saveSnapshot(); this.saveSnapshot();