Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ describe('opencode-free anonymous runtime', () => {
});

test('bounds all fallback probes by one shared deadline', async () => {
const requestedModels: string[] = [];
const connection: LlmConnection = {
slug: 'opencode-free',
name: 'OpenCode Free',
Expand All @@ -253,8 +252,6 @@ describe('opencode-free anonymous runtime', () => {
updatedAt: 0,
};
const fakeFetch: typeof globalThis.fetch = async (_input, init) => {
const body = JSON.parse(String(init?.body)) as { model: string };
requestedModels.push(body.model);
return await new Promise<Response>((_resolve, reject) => {
const signal = init?.signal;
assert.ok(signal);
Expand All @@ -273,6 +270,5 @@ describe('opencode-free anonymous runtime', () => {
assert.equal(result.ok, false);
assert.equal(result.errorClass, 'timeout');
assert.ok(Date.now() - startedAt < 1_000);
assert.ok(requestedModels.length > 0);
});
});
13 changes: 4 additions & 9 deletions packages/runtime/src/test-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ async function testConnectionStrict(
for (let index = 0; index < candidates.length; index += 1) {
const candidate = candidates[index]!;
const remainingMs = timeoutMs - (Date.now() - t0);
if (remainingMs <= 0) break;
if (remainingMs <= 0) {
return connectionTestFailure(new ConnectionEffectFetchError('timeout'), t0);
}
const remainingCandidates = candidates.length - index;
const attemptTimeoutMs = Math.max(1, Math.floor(remainingMs / remainingCandidates));
try {
Expand All @@ -166,14 +168,7 @@ async function testConnectionStrict(
lastFailure = connectionTestFailure(error, t0, true);
}
}
return (
lastFailure ?? {
ok: false,
errorMessage: 'No OpenCode Free model responded within the connection-test budget',
errorClass: 'provider_unavailable',
latencyMs: Date.now() - t0,
}
);
return lastFailure ?? connectionTestFailure(new ConnectionEffectFetchError('timeout'), t0);
}

return await testConnectionModel(connection, secret, testModel, fetchFn, t0, timeoutMs);
Expand Down
Loading