@devries-cameron20 / composio-1 / commits / c9c3e49fe
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

test(cli): wait for the hung host command before advancing the clock

The hung-native-host test forked setup, yielded once, then advanced the TestClock by two minutes. Setup does real file I/O before it reaches the host command, so on a slow CI worker the timeout was not yet armed when the clock moved; the sleep then waited forever and the test failed on vitest's own 15s limit. It flaked on next-based branches today, not only this one. The hanging runner now opens a latch when setup reaches it, and the test advances the clock only after that. Claude-Session: https://claude.ai/code/session_01MTb47vexN35pLGsSZwBmrJ

jkomyno committed Sep 14, 2026 at 16:19 UTC c9c3e49feef2d0e847abd0d5e7fa92832e65443c
1 file changed +9 -2
ts/packages/cli/test/src/commands/setup.cmd.test.ts
+9 -2
@@ -1,5 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 -import { Cause, Effect, Exit, Fiber } from 'effect';
2 +import { Cause, Effect, Exit, Fiber, Latch } from 'effect';
3 import { TestClock } from 'effect/testing';
4 import { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process';
5 import { afterEach, vi } from 'vitest';
@@ -1136,9 +1136,15 @@ describe('CLI: composio setup', () => {
1136 );
1137 });
1138
1139 + // Opens once setup reaches the host command. The command path does real
1140 + // file I/O first (config, analytics state), so a single yield is not enough
1141 + // to guarantee the 2-minute timeout has been armed on the TestClock before
1142 + // the clock is advanced; advancing too early leaves the sleep pending
1143 + // forever and the test hits vitest's own timeout instead.
1144 + const hostCommandReached = Latch.makeUnsafe(false);
1145 const hangingRunner = CommandRunner.of({
1146 run: () => Effect.succeed(ChildProcessSpawner.ExitCode(0)),
1141 - capture: () => Effect.never,
1147 + capture: () => Effect.andThen(hostCommandReached.open, Effect.never),
1148 });
1149 layer(TestLive({ commandRunner: hangingRunner }))('hung native host', it => {
1150 it.effect('times out instead of blocking setup forever', () =>
@@ -1147,6 +1153,7 @@ describe('CLI: composio setup', () => {
1153 Effect.exit,
1154 Effect.forkChild
1155 );
1156 + yield* hostCommandReached.await;
1157 yield* Effect.yieldNow;
1158 yield* TestClock.adjust('2 minutes');
1159 const exit = yield* Fiber.join(fiber);