Files
OmniRoute/tests/unit/safe-outbound-fetch-probe-timeout.test.ts
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

50 lines
2.2 KiB
TypeScript

import { describe, it, beforeEach, afterEach } from "node:test";
import assert from "node:assert/strict";
const ENV_KEY = "OMNIROUTE_PROVIDER_PROBE_TIMEOUT_MS";
const originalValue = process.env[ENV_KEY];
async function freshImport() {
// Force a fresh module evaluation so the env var read at module scope is re-applied.
const modUrl = `../../src/shared/network/safeOutboundFetch.ts?t=${Date.now()}-${Math.random()}`;
return import(modUrl);
}
describe("safeOutboundFetch — provider probe timeout (validationRead / modelsProbe)", () => {
afterEach(() => {
if (originalValue === undefined) delete process.env[ENV_KEY];
else process.env[ENV_KEY] = originalValue;
});
it("defaults validationRead and modelsProbe to 8000ms when no env override is set", async () => {
delete process.env[ENV_KEY];
const { SAFE_OUTBOUND_FETCH_PRESETS } = await freshImport();
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.validationRead.timeoutMs, 8000);
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.modelsProbe.timeoutMs, 8000);
});
it("honors OMNIROUTE_PROVIDER_PROBE_TIMEOUT_MS when set to a valid value", async () => {
process.env[ENV_KEY] = "12000";
const { SAFE_OUTBOUND_FETCH_PRESETS } = await freshImport();
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.validationRead.timeoutMs, 12000);
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.modelsProbe.timeoutMs, 12000);
});
it("falls back to the 8000ms default when the env value is invalid or too low", async () => {
process.env[ENV_KEY] = "not-a-number";
const invalid = await freshImport();
assert.equal(invalid.SAFE_OUTBOUND_FETCH_PRESETS.modelsProbe.timeoutMs, 8000);
process.env[ENV_KEY] = "500"; // below the 1000ms floor
const tooLow = await freshImport();
assert.equal(tooLow.SAFE_OUTBOUND_FETCH_PRESETS.modelsProbe.timeoutMs, 8000);
});
it("leaves validationWrite and modelsPagination unaffected by the probe timeout override", async () => {
process.env[ENV_KEY] = "12000";
const { SAFE_OUTBOUND_FETCH_PRESETS } = await freshImport();
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.validationWrite.timeoutMs, 15000);
assert.equal(SAFE_OUTBOUND_FETCH_PRESETS.modelsPagination.timeoutMs, 15000);
});
});