[DEBUG] Instrument askModel against @gradio/client@2.2.0
Browse files- index.html +19 -9
index.html
CHANGED
|
@@ -1093,9 +1093,24 @@ async function askModel(prompt, history, onChunk, onStatus){
|
|
| 1093 |
};
|
| 1094 |
arm();
|
| 1095 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
try {
|
| 1097 |
for await (const msg of job){
|
| 1098 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1099 |
if (timedOut) break;
|
| 1100 |
if (msg.type === "data" && msg.data && Array.isArray(msg.data)){
|
| 1101 |
const text = msg.data[0];
|
|
@@ -1108,21 +1123,16 @@ async function askModel(prompt, history, onChunk, onStatus){
|
|
| 1108 |
errorPayload = { title: msg.title || "", message: msg.message || "" };
|
| 1109 |
}
|
| 1110 |
if (onStatus) onStatus(msg);
|
| 1111 |
-
// @gradio/client@1.19.1 emits {type:"status", stage:"complete"} as the
|
| 1112 |
-
// FINAL event after the last data chunk but does not close the iterator.
|
| 1113 |
-
// Without this break the for-await hangs forever, _inflight never resets,
|
| 1114 |
-
// and the Send button stays disabled. Verified via in-browser console log
|
| 1115 |
-
// 2026-05-09: complete only fires after the last data event (event #107
|
| 1116 |
-
// at +5411ms, immediately after the final data event #106).
|
| 1117 |
if (msg.stage === "complete" || msg.stage === "error") {
|
| 1118 |
-
|
| 1119 |
-
// doesn't trigger close() on the AsyncIterator's return path.
|
| 1120 |
try { job.cancel?.(); } catch {}
|
| 1121 |
break;
|
| 1122 |
}
|
| 1123 |
}
|
| 1124 |
}
|
|
|
|
| 1125 |
} finally {
|
|
|
|
| 1126 |
if (watchdog) clearTimeout(watchdog);
|
| 1127 |
}
|
| 1128 |
|
|
|
|
| 1093 |
};
|
| 1094 |
arm();
|
| 1095 |
|
| 1096 |
+
// [DEBUG-2026-05-10] Instrumented for @gradio/client@2.2.0 — capture every
|
| 1097 |
+
// event + loop boundaries to identify the new exit signal.
|
| 1098 |
+
const _t0 = Date.now();
|
| 1099 |
+
const _dbg = (label, extra) => console.log(`[askModel +${Date.now()-_t0}ms] ${label}`, extra || "");
|
| 1100 |
+
_dbg("submit start", { client: "2.2.0", hasToken: !!getOAuthToken() });
|
| 1101 |
+
let _eventCount = 0;
|
| 1102 |
try {
|
| 1103 |
for await (const msg of job){
|
| 1104 |
+
_eventCount++;
|
| 1105 |
+
_dbg(`event #${_eventCount}`, {
|
| 1106 |
+
type: msg.type,
|
| 1107 |
+
stage: msg.stage,
|
| 1108 |
+
success: msg.success,
|
| 1109 |
+
hasData: !!msg.data,
|
| 1110 |
+
dataLen: Array.isArray(msg.data) && typeof msg.data[0] === "string" ? msg.data[0].length : null,
|
| 1111 |
+
keys: Object.keys(msg || {}),
|
| 1112 |
+
});
|
| 1113 |
+
arm();
|
| 1114 |
if (timedOut) break;
|
| 1115 |
if (msg.type === "data" && msg.data && Array.isArray(msg.data)){
|
| 1116 |
const text = msg.data[0];
|
|
|
|
| 1123 |
errorPayload = { title: msg.title || "", message: msg.message || "" };
|
| 1124 |
}
|
| 1125 |
if (onStatus) onStatus(msg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1126 |
if (msg.stage === "complete" || msg.stage === "error") {
|
| 1127 |
+
_dbg("breaking on stage", msg.stage);
|
|
|
|
| 1128 |
try { job.cancel?.(); } catch {}
|
| 1129 |
break;
|
| 1130 |
}
|
| 1131 |
}
|
| 1132 |
}
|
| 1133 |
+
_dbg("FOR-AWAIT EXITED", { totalEvents: _eventCount, lastLen: lastContent.length });
|
| 1134 |
} finally {
|
| 1135 |
+
_dbg("FINALLY", { _inflight_will_reset: true });
|
| 1136 |
if (watchdog) clearTimeout(watchdog);
|
| 1137 |
}
|
| 1138 |
|