fix(ollama-stream): 修复变量名错误和Node.js环境兼容性问题

This commit is contained in:
wd041216-bit 2026-03-18 20:35:38 +08:00
parent 72b139df08
commit 7f82d055fc

View File

@ -565,7 +565,7 @@ export async function* parseNdjsonStream(
// Reset buffer if we're done
if (done && accumulatedBuffer.trim()) {
try {
yield parseJsonPreservingUnsafeIntegers(accumBuffer.trim()) as OllamaChatResponse;
yield parseJsonPreservingUnsafeIntegers(accumulatedBuffer.trim()) as OllamaChatResponse;
} catch {
log.warn(`Skipping malformed trailing data: ${accumulatedBuffer.trim().slice(0, 120)}`);
}
@ -749,17 +749,6 @@ export function createOllamaStreamFn(
for await (const chunk of parseNdjsonStream(reader, config.bufferSize)) {
const currentTime = Date.now();
// Check connection health periodically
if (currentTime - lastConnectionCheck > connectionCheckInterval) {
if (!navigator.onLine) {
connectionHealthy = false;
log.warn("[manusilized] Connection lost, attempting to recover...");
} else {
connectionHealthy = true;
}
lastConnectionCheck = currentTime;
}
// Throttle streaming to reduce UI updates
if (currentTime - lastStreamTime < config.throttleDelay) {
continue;