xonecas.io
64875
Mc

mini-coder / commit e7eaa0d

fix: add chunk timeout to streamText to prevent silent ECONNRESET

Proxy idle timeouts (~60s) kill long-running streams when a model
spends >60s generating a large tool-call argument before the first
chunk arrives. Setting timeout.chunkMs to 120s surfaces a clean
error instead of a silent connection drop.

xonecas2026-03-14 e7eaa0dc87a90ef8f2731d6a71a9ced129d86e7f parent 7477de9

1 file changed

src/llm-api/turn.ts+5−0
@@ -1085,6 +1085,11 @@ export async function* runTurn(options: {
10851085 ? { providerOptions: mergedProviderOptions }
10861086 : {}),
10871087 ...(signal ? { abortSignal: signal } : {}),
1088+ // Guard against proxy idle-timeout killing long-running streams (e.g. when
1089+ // a model spends >60 s generating a large tool-call argument before the
1090+ // first chunk arrives). 120 s gives plenty of headroom for slow models
1091+ // while still surfacing a clean error instead of a silent ECONNRESET.
1092+ timeout: { chunkMs: 120_000 },
10881093 };
10891094
10901095 const result = streamText(streamOpts) as StreamTextResultFull;