Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(check-fetch-timeouts): stop reporting a fetch that lives inside a string

nirholase161cdad7da2
diff --git a/api/avatar-stream.js b/api/avatar-stream.js
index 2f4f14d4a..fb7c7f0e3 100644
--- a/api/avatar-stream.js
+++ b/api/avatar-stream.js
@@ -55,7 +55,7 @@ async function loadSource(src) {
// Caller-supplied source URL: bounded so a host that accepts the connection
// and then stalls cannot hold the frame request open until the platform
// kills it. SSRF validation happens above; this is the time budget.
- const response = await fetch(src, { redirect: 'follow' });
+ const response = await fetch(src, { redirect: 'follow', signal: AbortSignal.timeout(20_000) });
if (!response.ok) throw Object.assign(new Error(`upstream ${response.status}`), { status: 502 });
return new Uint8Array(await response.arrayBuffer());
}
diff --git a/scripts/check-fetch-timeouts.mjs b/scripts/check-fetch-timeouts.mjs
index 7d41936f1..7fae756d2 100644
--- a/scripts/check-fetch-timeouts.mjs
+++ b/scripts/check-fetch-timeouts.mjs
@@ -131,6 +131,26 @@ function isQuotedSource(line) {
return /^\s*[`'"]/.test(line);
}
+// True when the `fetch(` on this line sits INSIDE a string literal rather than
+// being a call. Documentation strings and usage examples embedded in an API
+// response ship real code as data, and reporting those trains people to ignore
+// this check, which is worse than the gap it would close.
+function fetchIsInsideString(line) {
+ const idx = line.search(/(?<![.\w$])fetch\s*\(/);
+ if (idx < 0) return false;
+ let quote = null;
+ for (let i = 0; i < idx; i++) {
+ const ch = line[i];
+ if (quote) {
+ if (ch === '\\') i += 1;
+ else if (ch === quote) quote = null;
+ } else if (ch === '\'' || ch === '"' || ch === '`') {
+ quote = ch;
+ }
+ }
+ return quote !== null;
+}
+
export function scanFile(file, src) {
// Server handlers and helpers: every call is in scope, same-origin included.
const serverSide = /^api\//.test(file);
@@ -139,8 +159,12 @@ export function scanFile(file, src) {
const out = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
- if (!/\bfetch\(/.test(line)) continue;
+ // A member call (`client.fetch(...)`, `Model.fetch()`) is somebody else's
+ // method, not the global fetch: an IMAP client and an SDK helper both
+ // spell it this way and neither opens an HTTP socket we control.
+ if (!/(?<![.\w$])fetch\s*\(/.test(line)) continue;
if (/^\s*(\/\/|\*|\/\*)/.test(line)) continue;
+ if (fetchIsInsideString(line)) continue;
// Definitions, stubs and re-assignments are not call sites.
if (/function fetch|globalThis\.fetch\s*=|global\.fetch\s*=|vi\.fn|fetchImpl\b|=\s*fetch\s*[;,)]/.test(line)) continue;