Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Fix composio link hanging after auth completes (#3009)
## Summary - Fixed `composio link` waiting on the wrong project/client scope after creating an auth link. - Changed the wait path to poll the connected account with the exact same client instance that created the link. - This keeps the link creation and ACTIVE-status polling in the same org/project context so the CLI exits once auth completes. ## Testing - Not run: local test suite. - Reason: this worktree does not have `node_modules` installed, so `vitest` is unavailable here.
Rahul Tarak committed
Mar 24, 2026 at 17:55 UTC
490a63765664e8c055c8f5ba952c0b4a562c97de
3 files changed
+20
-6
ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
+7
-6
@@ -1,7 +1,7 @@
1
import { Args, Command, Options } from '@effect/cli';
2
import { Effect, Option, Schedule } from 'effect';
3
+import type { Composio as RawComposioClient } from '@composio/client';
4
import open from 'open';
4
-import { ComposioToolkitsRepository } from 'src/services/composio-clients';
5
import { ComposioUserContext } from 'src/services/user-context';
6
import { TerminalUI } from 'src/services/terminal-ui';
7
import { requireAuth } from 'src/effects/require-auth';
@@ -48,7 +48,7 @@ const noWait = Options.boolean('no-wait').pipe(
48
49
const waitForActiveConnection = (
50
ui: TerminalUI,
51
- repo: ComposioToolkitsRepository,
51
+ client: RawComposioClient,
52
connectedAccountId: string,
53
redirectUrl: string,
54
noBrowser: boolean
@@ -84,7 +84,9 @@ const waitForActiveConnection = (
84
yield* ui.useMakeSpinner('Waiting for authentication...', spinner =>
85
Effect.retry(
86
Effect.gen(function* () {
87
- const account = yield* repo.getConnectedAccount(connectedAccountId);
87
+ const account = yield* Effect.tryPromise(() =>
88
+ client.connectedAccounts.retrieve(connectedAccountId)
89
+ );
90
if (account.status === 'ACTIVE') {
91
return account;
92
}
@@ -160,7 +162,6 @@ const runConnectedAccountsLink = (params: {
162
if (!(yield* requireAuth)) return;
163
164
const ui = yield* TerminalUI;
163
- const repo = yield* ComposioToolkitsRepository;
165
const clientSingleton = yield* ComposioClientSingleton;
166
const projectContext = yield* ProjectContext;
167
const userContext = yield* ComposioUserContext;
@@ -279,7 +280,7 @@ const runConnectedAccountsLink = (params: {
280
)
281
);
282
} else {
282
- yield* waitForActiveConnection(ui, repo, connId, redirectUrl, params.noBrowser);
283
+ yield* waitForActiveConnection(ui, client, connId, redirectUrl, params.noBrowser);
284
}
285
return;
286
}
@@ -371,7 +372,7 @@ const runConnectedAccountsLink = (params: {
372
},
373
}).pipe(Effect.catchAll(() => Effect.void));
374
} else {
374
- yield* waitForActiveConnection(ui, repo, connAccountId, redirectUrl, params.noBrowser);
375
+ yield* waitForActiveConnection(ui, client, connAccountId, redirectUrl, params.noBrowser);
376
yield* appendCliSessionHistory({
377
orgId: resolvedProject.projectType === 'CONSUMER' ? resolvedProject.orgId : undefined,
378
consumerUserId:
ts/packages/cli/test/__utils__/services/test-layer.ts
+9
@@ -931,6 +931,15 @@ export const TestLayer = (input?: TestLiveInput) =>
931
return response;
932
},
933
},
934
+ connectedAccounts: {
935
+ retrieve: async (nanoid: string) => {
936
+ const found = connectedAccountsData.items.find(item => item.id === nanoid);
937
+ if (!found) {
938
+ throw new Error(`Connected account "${nanoid}" not found`);
939
+ }
940
+ return found;
941
+ },
942
+ },
943
toolkits: {
944
retrieve: async (slug: string) => {
945
const detailed = toolkitsData.detailedToolkits.find(
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+4
@@ -7,6 +7,7 @@ import { ComposioNoActiveConnectionError } from 'src/services/composio-error-ove
7
import { setupCacheDir } from 'src/effects/setup-cache-dir';
8
import { getOrFetchToolInputDefinition } from 'src/services/tool-input-validation';
9
import * as consumerShortTermCache from 'src/services/consumer-short-term-cache';
10
+import * as composioClients from 'src/services/composio-clients';
11
import * as redactModule from 'src/ui/redact';
12
import { cli, TestLive, MockConsole } from 'test/__utils__';
13
import type { TestLiveInput } from 'test/__utils__/services/test-layer';
@@ -42,6 +43,9 @@ describe('CLI: composio execute', () => {
43
beforeEach(() => {
44
savedCI = process.env.CI;
45
delete process.env.CI;
46
+ vi.spyOn(composioClients, 'getLatestToolVersion').mockImplementation(() =>
47
+ Effect.fail(new composioClients.HttpServerError({}))
48
+ );
49
vi.spyOn(consumerShortTermCache, 'getFreshConsumerConnectedToolkitsFromCache').mockReturnValue(
50
Effect.succeed(Option.some(['gmail', 'github']))
51
);