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
21 changes: 21 additions & 0 deletions packages/cli/src/ui/utils/goal-runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ describe('waitForGoalRuntime', () => {
);
});

it('allows Goal-less sessions when readiness throws synchronously', async () => {
const getGoalRuntimeReady = vi.fn((): Promise<GoalRuntime> => {
throw new GoalPersistenceUnavailableError();
});

await expect(
waitForGoalRuntime({ getGoalRuntimeReady }, { timeoutMs: 100 }),
).resolves.toBe(true);
});

it('does not hide synchronous readiness errors', async () => {
const failure = new Error('unsupported Goal lifecycle record');
const getGoalRuntimeReady = vi.fn((): Promise<GoalRuntime> => {
throw failure;
});

await expect(waitForGoalRuntime({ getGoalRuntimeReady })).rejects.toBe(
failure,
);
});

it('resolves true once the runtime settles within the timeout', async () => {
const getGoalRuntimeReady = vi.fn().mockResolvedValue({});
await expect(
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/ui/utils/goal-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ export async function waitForGoalRuntime(
config: Pick<Config, 'getGoalRuntimeReady'>,
options: { timeoutMs?: number } = {},
): Promise<boolean> {
const ready = config.getGoalRuntimeReady();
const awaitReady = async (): Promise<void> => {
try {
await ready;
await config.getGoalRuntimeReady();
} catch (error) {
if (!(error instanceof GoalPersistenceUnavailableError)) throw error;
}
Expand Down
Loading