diff --git a/open-sse/executors/base.js b/open-sse/executors/base.js index a4c017e4..7dbb0700 100644 --- a/open-sse/executors/base.js +++ b/open-sse/executors/base.js @@ -139,8 +139,6 @@ export class BaseExecutor { try { const bodyStr = JSON.stringify(transformedBody); - const fetchT0 = Date.now(); - dbg("FETCH", `${this.provider.toUpperCase()} → ${url} | body=${bodyStr.length}B | connectTimeout=${timeoutMs}ms`); const response = await proxyAwareFetch(url, { method: "POST", headers, @@ -148,9 +146,6 @@ export class BaseExecutor { signal: mergedSignal }, proxyOptions); clearTimeout(connectTimer); - const ct = response.headers?.get?.("content-type") || ""; - const cl = response.headers?.get?.("content-length") || "?"; - dbg("FETCH", `${this.provider.toUpperCase()} ← ${response.status} | ttft=${Date.now() - fetchT0}ms | ct=${ct} | cl=${cl}`); if (await tryRetry(urlIndex, response.status, `status ${response.status}`, response)) { urlIndex--; continue; } diff --git a/open-sse/executors/freebuff.js b/open-sse/executors/freebuff.js index 4f23e630..891a44a0 100644 --- a/open-sse/executors/freebuff.js +++ b/open-sse/executors/freebuff.js @@ -491,19 +491,14 @@ export class FreebuffExecutor extends BaseExecutor { for (let attempt = 0; ; attempt++) { const transformedBody = buildBody(); const bodyStr = JSON.stringify(transformedBody); - dbg("FETCH", `FREEBUFF → ${url} | body=${bodyStr.length}B`); const connectCtrl = new AbortController(); const timeoutMs = this.config?.timeoutMs || FETCH_CONNECT_TIMEOUT_MS; const connectTimer = setTimeout(() => connectCtrl.abort(new Error("fetch connect timeout")), timeoutMs); const mergedSignal = signal ? AbortSignal.any([signal, connectCtrl.signal]) : connectCtrl.signal; - const fetchT0 = Date.now(); let response; try { response = await proxyAwareFetch(url, { method: "POST", headers, body: bodyStr, signal: mergedSignal }, proxyOptions); - const ct = response.headers?.get?.("content-type") || ""; - const cl = response.headers?.get?.("content-length") || "?"; - dbg("FETCH", `FREEBUFF ← ${response.status} | ttft=${Date.now() - fetchT0}ms | ct=${ct} | cl=${cl}`); } catch (error) { // A caller/stream abort (AbortError) is genuine — never retry it. A // transient socket/TLS reset (same class as the run-registration diff --git a/open-sse/utils/stream.js b/open-sse/utils/stream.js index 33e7fb04..87681089 100644 --- a/open-sse/utils/stream.js +++ b/open-sse/utils/stream.js @@ -338,8 +338,6 @@ export function createSSEStream(options = {}) { }, flush(controller) { - const evtSummary = Object.entries(eventTypeCounts).map(([k, v]) => `${k}=${v}`).join(",") || "none"; - dbg("SSE", `flush | provider=${provider} | model=${model} | recvLines=${sseLineCount} | emitted=${sseEmittedCount} | events=[${evtSummary}]`); trackPendingRequest(model, provider, connectionId, false); try { const remaining = decoder.decode(); diff --git a/open-sse/utils/streamHandler.js b/open-sse/utils/streamHandler.js index 7f04427d..8e818a3d 100644 --- a/open-sse/utils/streamHandler.js +++ b/open-sse/utils/streamHandler.js @@ -1,6 +1,6 @@ // Stream handler with disconnect detection - shared for all providers import { STREAM_STALL_TIMEOUT_MS } from "../config/runtimeConfig.js"; -import { dbg, isDebugEnabled } from "./debugLog.js"; +import { dbg } from "./debugLog.js"; // Get HH:MM:SS timestamp function getTimeString() { @@ -190,11 +190,6 @@ export function createDisconnectAwareStream(transformStream, streamController, o */ export function pipeWithDisconnect(providerResponse, transformStream, streamController, onAbortTerminal = null, stallTimeoutMs = STREAM_STALL_TIMEOUT_MS) { let stallTimer = null; - let chunkCount = 0; - let totalBytes = 0; - let lastChunkAt = Date.now(); - const t0 = Date.now(); - const tag = "STREAM"; const clearStall = () => { if (stallTimer) { clearTimeout(stallTimer); stallTimer = null; } }; @@ -202,7 +197,6 @@ export function pipeWithDisconnect(providerResponse, transformStream, streamCont clearStall(); stallTimer = setTimeout(() => { stallTimer = null; - dbg(tag, `STALL TIMEOUT ${stallTimeoutMs}ms | chunks=${chunkCount} | bytes=${totalBytes} | sinceLast=${Date.now() - lastChunkAt}ms`); streamController.handleError?.(new Error("stream stall timeout")); streamController.abort?.(); }, stallTimeoutMs); @@ -215,30 +209,20 @@ export function pipeWithDisconnect(providerResponse, transformStream, streamCont signal: streamController.signal, startTime: streamController.startTime, isConnected: () => streamController.isConnected(), - handleComplete: () => { dbg(tag, `complete | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleComplete(); }, - handleError: (e) => { dbg(tag, `error: ${e?.message} | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleError(e); }, - handleDisconnect: (r) => { dbg(tag, `disconnect: ${r} | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleDisconnect(r); }, + handleComplete: () => { clearStall(); streamController.handleComplete(); }, + handleError: (e) => { clearStall(); streamController.handleError(e); }, + handleDisconnect: (r) => { clearStall(); streamController.handleDisconnect(r); }, abort: () => { clearStall(); streamController.abort(); } }; armStall(); - dbg(tag, `pipe start | stallTimeout=${stallTimeoutMs}ms`); const upstreamTap = new TransformStream({ transform(chunk, controller) { - chunkCount++; - const sz = chunk?.byteLength || chunk?.length || 0; - totalBytes += sz; - const now = Date.now(); - const gap = now - lastChunkAt; - lastChunkAt = now; - if (isDebugEnabled && (chunkCount <= 5 || chunkCount % 20 === 0 || gap > 5000)) { - dbg(tag, `chunk #${chunkCount} | size=${sz}B | gap=${gap}ms | total=${totalBytes}B`); - } armStall(); controller.enqueue(chunk); }, - flush() { dbg(tag, `upstream EOF | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); } + flush() { clearStall(); } }); const transformedBody = providerResponse.body