Skip to content

Commit d0c75f7

Browse files
only21milclaude
andcommitted
test(opencode): cover the text generation limit while session.create stalls
The 3-minute limit wraps the whole run, so a session.create that never settles must also end with the timeout error, cancel the request and send no prompt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1574077 commit d0c75f7

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/provider-opencode/src/server/textGeneration.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,29 @@ it.layer(layerOpenCodeTextGenerationTest)("OpenCodeTextGeneration", (it) => {
385385
),
386386
);
387387

388+
it.effect("gives up when session creation never settles", () =>
389+
withOpenCodeTextGeneration(DEFAULT_OPENCODE_SETTINGS, (textGeneration) =>
390+
Effect.gen(function* () {
391+
const started = yield* Deferred.make<AbortSignal | undefined>();
392+
runtimeMock.state.onSessionCreate = (signal) => {
393+
Deferred.doneUnsafe(started, Effect.succeed(signal));
394+
return new Promise<never>(() => {});
395+
};
396+
const fiber = yield* textGeneration
397+
.generateCommitMessage(DEFAULT_COMMIT_MESSAGE_INPUT)
398+
.pipe(Effect.forkChild);
399+
const signal = yield* Deferred.await(started);
400+
yield* TestClock.adjust(Duration.minutes(3));
401+
402+
const error = yield* Fiber.join(fiber).pipe(Effect.flip);
403+
expect(error).toBeInstanceOf(TextGenerationError);
404+
expect(error.detail).toBe("OpenCode did not finish generating in time.");
405+
expect(signal?.aborted).toBe(true);
406+
expect(runtimeMock.state.promptUrls).toEqual([]);
407+
}),
408+
),
409+
);
410+
388411
it.effect("uses an environment-only password for a locally spawned server", () =>
389412
withOpenCodeTextGeneration(
390413
DEFAULT_OPENCODE_SETTINGS,

0 commit comments

Comments
 (0)