API client: a 200 that is not JSON is said plainly instead of failing as 'r is null'

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BzJLJWVu7RZnbRqm3nYAnX
This commit is contained in:
Claude
2026-10-27 08:42:42 +00:00
parent e4111cf74a
commit eac7ecd582
+3
View File
@@ -16,6 +16,9 @@ export async function call(method, path, body) {
});
const payload = await res.json().catch(() => null);
if (!res.ok) throw Object.assign(new Error(why(res, payload)), { status: res.status }); // status: a refusal (4xx) is not an outage
// A 200 that is not JSON is not FunUI answering (ComfyUI restarting, a proxy's page, a route this server does not have):
// saying so beats every caller failing on "r is null".
if (payload === null && res.status !== 204) throw Object.assign(new Error(`FunUI did not answer ${path} (ComfyUI may be restarting, or this page is older than the server: reload the page).`), { status: 502 });
return payload;
}