diff --git a/packages/cli/src/ui/utils/goal-runtime.test.ts b/packages/cli/src/ui/utils/goal-runtime.test.ts index affa44ea4ee..f07a3e38725 100644 --- a/packages/cli/src/ui/utils/goal-runtime.test.ts +++ b/packages/cli/src/ui/utils/goal-runtime.test.ts @@ -37,6 +37,27 @@ describe('waitForGoalRuntime', () => { ); }); + it('allows Goal-less sessions when readiness throws synchronously', async () => { + const getGoalRuntimeReady = vi.fn((): Promise => { + 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 => { + 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( diff --git a/packages/cli/src/ui/utils/goal-runtime.ts b/packages/cli/src/ui/utils/goal-runtime.ts index dc8064e1665..373f3d57737 100644 --- a/packages/cli/src/ui/utils/goal-runtime.ts +++ b/packages/cli/src/ui/utils/goal-runtime.ts @@ -54,10 +54,9 @@ export async function waitForGoalRuntime( config: Pick, options: { timeoutMs?: number } = {}, ): Promise { - const ready = config.getGoalRuntimeReady(); const awaitReady = async (): Promise => { try { - await ready; + await config.getGoalRuntimeReady(); } catch (error) { if (!(error instanceof GoalPersistenceUnavailableError)) throw error; }