I'm struggling to investigate why there'
I'm struggling to investigate why there's a seven-second delay between the final output of a stream and the stream finishing
for await (const chunk of stream) {
debugLog(`๐ RAW CHUNK: ${JSON.stringify(chunk)}`);
const outputFromPrompt = chunk.output as Schema | null;
// Skip null/undefined chunks
if (!outputFromPrompt) {
continue;
}
debugLog('๐ค SENDING: chunk');
sendChunk(outputFromPrompt);
}
debugLog('โ
STREAM FINISHED');for await (const chunk of stream) {
debugLog(`๐ RAW CHUNK: ${JSON.stringify(chunk)}`);
const outputFromPrompt = chunk.output as Schema | null;
// Skip null/undefined chunks
if (!outputFromPrompt) {
continue;
}
debugLog('๐ค SENDING: chunk');
sendChunk(outputFromPrompt);
}
debugLog('โ
STREAM FINISHED');2025-06-10T16:12:49.407Z: ๐ RAW CHUNK: {"role":"model","index":0,"content":[{"text":""}]}
2025-06-10T16:12:49.407Z: ๐ค SENDING: chunk
2025-06-10T16:12:56.797Z: โ
STREAM FINISHED // seven second delay between final chunk and stream finishing2025-06-10T16:12:49.407Z: ๐ RAW CHUNK: {"role":"model","index":0,"content":[{"text":""}]}
2025-06-10T16:12:49.407Z: ๐ค SENDING: chunk
2025-06-10T16:12:56.797Z: โ
STREAM FINISHED // seven second delay between final chunk and stream finishing