fix(bridge): remove abort signal and timeout for SDK permissions#31
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
In SDK mode, the
canUseToolcallback receives anAbortSignalfrom 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.tssignaltoonAskUserQuestionhandlersignal.abortedbefore forwarding permission requestssignaltoonPermissionRequesthandlerbridge/src/engine/bridge-manager.tssdkPermissionHandler: remove abort listener + cleanup, remove 5-min timeoutsdkAskQuestionHandler: remove abort listener + cleanup, remove 5-min timeoutRationale
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 errorsnpm test— 443 tests passed