Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): a rejecting body read no longer fails the whole readiness request

[._.]/ Adam Eivy362ee27b2540
diff --git a/server/lib/openAiModelsProbe.js b/server/lib/openAiModelsProbe.js
index 10f25639ba..d70531589d 100644
--- a/server/lib/openAiModelsProbe.js
+++ b/server/lib/openAiModelsProbe.js
@@ -57,7 +57,13 @@ export async function probeOpenAiModels(baseUrl, { timeoutMs = 2_000 } = {}) {
return { reachable: false, models: null, error: `HTTP ${res.status}` };
}
- const body = await readResponseJson(res, { fallback: null, emptyValue: null });
+ // The body read is its own failure path: a daemon that accepts the connection
+ // and then drops it (or sends a truncated body) rejects inside `res.text()`,
+ // NOT at the fetch above. Unhandled, that rejection escapes the probe and
+ // fails the entire readiness request — one flaky daemon would blank the
+ // checklist for every provider — so it lands on the same
+ // reachable-but-unreadable sentinel as a non-JSON body.
+ const body = await readResponseJson(res, { fallback: null, emptyValue: null }).catch(() => null);
const rows = Array.isArray(body?.data) ? body.data : Array.isArray(body?.models) ? body.models : null;
if (!rows) return { reachable: true, models: null, error: 'model listing was not readable' };
return {
diff --git a/server/lib/openAiModelsProbe.test.js b/server/lib/openAiModelsProbe.test.js
index 24f02db984..a8d36a7cbd 100644
--- a/server/lib/openAiModelsProbe.test.js
+++ b/server/lib/openAiModelsProbe.test.js
@@ -45,6 +45,15 @@ describe('probeOpenAiModels', () => {
expect(unreadable.error).toMatch(/not readable/i);
});
+ it('survives a body that rejects mid-read', async () => {
+ // A daemon that accepts the connection and then drops it rejects in
+ // res.text(), not at the fetch. Escaping here would fail the whole
+ // readiness request and blank the checklist for every provider.
+ mockFetch(async () => ({ ok: true, status: 200, text: async () => { throw new Error('terminated'); } }));
+
+ await expect(probeOpenAiModels('http://x/v1')).resolves.toMatchObject({ reachable: true, models: null });
+ });
+
it('names the real transport failure instead of undici bare "fetch failed"', async () => {
const err = new TypeError('fetch failed');
err.cause = Object.assign(new Error('connect ECONNREFUSED 127.0.0.1:8080'), { code: 'ECONNREFUSED' });