chore: strip per-request DEBUG logs from chat path

Remove [DBG:STREAM] chunk/pipe/EOF instrumentation and [DBG:SSE] flush +
fetch success lines that spam the dev console every request. Keep the stream
stall watchdog and the fetch-error (✖) diagnostics.
This commit is contained in:
MUH. IQRAM BAHRING committed 2026-08-07 04:24:54 +08:00
1 parent ad43a267ac
commit 041e039793
4 files changed
+5 -33

No files matched your search

-5
View File
@@ -139,8 +139,6 @@ export class BaseExecutor {
try { try {
const bodyStr = JSON.stringify(transformedBody); 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, { const response = await proxyAwareFetch(url, {
method: "POST", method: "POST",
headers, headers,
@@ -148,9 +146,6 @@ export class BaseExecutor {
signal: mergedSignal signal: mergedSignal
}, proxyOptions); }, proxyOptions);
clearTimeout(connectTimer); 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; } if (await tryRetry(urlIndex, response.status, `status ${response.status}`, response)) { urlIndex--; continue; }
-5
View File
@@ -491,19 +491,14 @@ export class FreebuffExecutor extends BaseExecutor {
for (let attempt = 0; ; attempt++) { for (let attempt = 0; ; attempt++) {
const transformedBody = buildBody(); const transformedBody = buildBody();
const bodyStr = JSON.stringify(transformedBody); const bodyStr = JSON.stringify(transformedBody);
dbg("FETCH", `FREEBUFF → ${url} | body=${bodyStr.length}B`);
const connectCtrl = new AbortController(); const connectCtrl = new AbortController();
const timeoutMs = this.config?.timeoutMs || FETCH_CONNECT_TIMEOUT_MS; const timeoutMs = this.config?.timeoutMs || FETCH_CONNECT_TIMEOUT_MS;
const connectTimer = setTimeout(() => connectCtrl.abort(new Error("fetch connect timeout")), timeoutMs); const connectTimer = setTimeout(() => connectCtrl.abort(new Error("fetch connect timeout")), timeoutMs);
const mergedSignal = signal ? AbortSignal.any([signal, connectCtrl.signal]) : connectCtrl.signal; const mergedSignal = signal ? AbortSignal.any([signal, connectCtrl.signal]) : connectCtrl.signal;
const fetchT0 = Date.now();
let response; let response;
try { try {
response = await proxyAwareFetch(url, { method: "POST", headers, body: bodyStr, signal: mergedSignal }, proxyOptions); 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) { } catch (error) {
// A caller/stream abort (AbortError) is genuine — never retry it. A // A caller/stream abort (AbortError) is genuine — never retry it. A
// transient socket/TLS reset (same class as the run-registration // transient socket/TLS reset (same class as the run-registration
-2
View File
@@ -338,8 +338,6 @@ export function createSSEStream(options = {}) {
}, },
flush(controller) { 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); trackPendingRequest(model, provider, connectionId, false);
try { try {
const remaining = decoder.decode(); const remaining = decoder.decode();
+5 -21
View File
@@ -1,6 +1,6 @@
// Stream handler with disconnect detection - shared for all providers // Stream handler with disconnect detection - shared for all providers
import { STREAM_STALL_TIMEOUT_MS } from "../config/runtimeConfig.js"; 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 // Get HH:MM:SS timestamp
function getTimeString() { 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) { export function pipeWithDisconnect(providerResponse, transformStream, streamController, onAbortTerminal = null, stallTimeoutMs = STREAM_STALL_TIMEOUT_MS) {
let stallTimer = null; let stallTimer = null;
let chunkCount = 0;
let totalBytes = 0;
let lastChunkAt = Date.now();
const t0 = Date.now();
const tag = "STREAM";
const clearStall = () => { const clearStall = () => {
if (stallTimer) { clearTimeout(stallTimer); stallTimer = null; } if (stallTimer) { clearTimeout(stallTimer); stallTimer = null; }
}; };
@@ -202,7 +197,6 @@ export function pipeWithDisconnect(providerResponse, transformStream, streamCont
clearStall(); clearStall();
stallTimer = setTimeout(() => { stallTimer = setTimeout(() => {
stallTimer = null; 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.handleError?.(new Error("stream stall timeout"));
streamController.abort?.(); streamController.abort?.();
}, stallTimeoutMs); }, stallTimeoutMs);
@@ -215,30 +209,20 @@ export function pipeWithDisconnect(providerResponse, transformStream, streamCont
signal: streamController.signal, signal: streamController.signal,
startTime: streamController.startTime, startTime: streamController.startTime,
isConnected: () => streamController.isConnected(), isConnected: () => streamController.isConnected(),
handleComplete: () => { dbg(tag, `complete | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleComplete(); }, handleComplete: () => { clearStall(); streamController.handleComplete(); },
handleError: (e) => { dbg(tag, `error: ${e?.message} | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleError(e); }, handleError: (e) => { clearStall(); streamController.handleError(e); },
handleDisconnect: (r) => { dbg(tag, `disconnect: ${r} | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); streamController.handleDisconnect(r); }, handleDisconnect: (r) => { clearStall(); streamController.handleDisconnect(r); },
abort: () => { clearStall(); streamController.abort(); } abort: () => { clearStall(); streamController.abort(); }
}; };
armStall(); armStall();
dbg(tag, `pipe start | stallTimeout=${stallTimeoutMs}ms`);
const upstreamTap = new TransformStream({ const upstreamTap = new TransformStream({
transform(chunk, controller) { 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(); armStall();
controller.enqueue(chunk); controller.enqueue(chunk);
}, },
flush() { dbg(tag, `upstream EOF | chunks=${chunkCount} | bytes=${totalBytes} | dur=${Date.now() - t0}ms`); clearStall(); } flush() { clearStall(); }
}); });
const transformedBody = providerResponse.body const transformedBody = providerResponse.body