Skip to content

fix(bridge): remove abort signal and timeout for SDK permissions#31

Merged
y49 merged 1 commit into
mainfrom
fix/sdk-abort-timeout
Apr 6, 2026
Merged

fix(bridge): remove abort signal and timeout for SDK permissions#31
y49 merged 1 commit into
mainfrom
fix/sdk-abort-timeout

Conversation

@y49

@y49 y49 commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Remove SDK abort signal handling from permission requests and AskUserQuestion in IM bridge
  • Remove 5-minute timeout — IM users may respond hours or days later
  • Fix race condition where SDK abort could deny permissions before they reach the user

Problem

In SDK mode, the canUseTool callback receives an AbortSignal from the SDK. When the SDK cancels a request (e.g., subagent stopped, query ended), the abort handler immediately resolves permissions as "deny" and skips AskUserQuestion — before the user even sees the card on Telegram/Discord/Feishu.

The 5-minute timeout also prematurely denies permissions for IM users who are away from their phone.

Changes

bridge/src/providers/claude-sdk.ts

  • Don't pass signal to onAskUserQuestion handler
  • Don't check signal.aborted before forwarding permission requests
  • Don't pass signal to onPermissionRequest handler

bridge/src/engine/bridge-manager.ts

  • sdkPermissionHandler: remove abort listener + cleanup, remove 5-min timeout
  • sdkAskQuestionHandler: remove abort listener + cleanup, remove 5-min timeout
  • Both now wait indefinitely for user response via IM

Rationale

The official SDK docs describe the abort signal as just "a cancellation signal" — not mandatory to honor. The SDK doesn't even use it yet. In IM context, the user controls when to respond; the SDK should not make that decision.

Test plan

  • npx tsc --noEmit — zero errors
  • npm test — 443 tests passed
  • Manual: trigger permission request via IM, verify no timeout
  • Manual: trigger AskUserQuestion via IM, verify no abort

…AskUserQuestion

In IM context, users may respond hours or even days later. The SDK's
abort signal and 5-minute timeout were prematurely denying permissions
and skipping questions before users could see them.

Changes:
- Remove abort signal listener from sdkPermissionHandler
- Remove abort signal listener from sdkAskQuestionHandler
- Remove 5-minute timeout from both handlers (wait indefinitely)
- Stop passing abort signal from claude-sdk.ts canUseTool to handlers
- Remove early abort check that auto-denied permissions

This fixes a race condition where the SDK could cancel a permission
request or question before it was even sent to the IM platform.
@y49 y49 merged commit ed92347 into main Apr 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant