feat: Add AbortSignal support for cancelling long-running operations#153
Open
sarthakNITT wants to merge 2 commits into
Open
feat: Add AbortSignal support for cancelling long-running operations#153sarthakNITT wants to merge 2 commits into
AbortSignal support for cancelling long-running operations#153sarthakNITT wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds local request-cancellation support to the iOS instance client by threading AbortSignal through client options and WebSocket request handling.
Changes:
- Extend
AppInstallationOptionsandperformActionsoptions to accept an optionalAbortSignal. - Update
sendRequestto reject with anAbortErrorwhen aborted and to clean up pending requests. - Propagate
options.signalinto calls that usesendRequest.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1447
to
+1457
| let abortListener: (() => void) | undefined; | ||
| if (signal) { | ||
| abortListener = () => { | ||
| clearTimeout(timeout); | ||
| pendingRequests.delete(id); | ||
| const err = new Error('The operation was aborted'); | ||
| err.name = 'AbortError'; | ||
| reject(err); | ||
| }; | ||
| signal.addEventListener('abort', abortListener); | ||
| } |
Comment on lines
1469
to
1472
| const timeout = setTimeout(() => { | ||
| pendingRequests.delete(id); | ||
| reject(new Error(`Request ${type} timed out`)); | ||
| cleanupAndReject(new Error(`Request ${type} timed out`)); | ||
| }, timeoutMs); |
Comment on lines
+1449
to
+1456
| abortListener = () => { | ||
| clearTimeout(timeout); | ||
| pendingRequests.delete(id); | ||
| const err = new Error('The operation was aborted'); | ||
| err.name = 'AbortError'; | ||
| reject(err); | ||
| }; | ||
| signal.addEventListener('abort', abortListener); |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cf46ab7. Configure here.
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.

Description
Fixes #152
This PR adds
AbortSignalsupport to the iOS SDK, allowing consumers to manually cancel long-running requests likeinstallAppandperformActionsusing a standardAbortControllerwithout having to wait for the client-side timeout to expire.Changes Made
AppInstallationOptions: Addedsignal?: AbortSignalproperty.InstanceClient: UpdatedperformActionssignature to accept an optionalsignal.sendRequest:signal?: AbortSignalparameter.abortevent listener that immediately callsclearTimeout, removes the request ID from thependingRequestsMap, and rejects the promise with anAbortError.Note
Low Risk
Client-only cancellation of in-flight requests; does not change server protocol or security-sensitive paths.
Overview
Adds optional
AbortSignalsupport so callers can cancel long-running WebSocket requests without waiting for the client timeout.sendRequestnow accepts an optional signal: it rejects immediately withAbortErrorif already aborted, registers a one-shotabortlistener that clears the request timeout, drops the pending entry, and rejects; resolve/reject paths remove the listener to avoid leaks.installAppexposesoptions.signalviaAppInstallationOptions;performActionsacceptsoptions.signaland passes it through with the existing dynamic timeout.Reviewed by Cursor Bugbot for commit 6e84380. Bugbot is set up for automated code reviews on this repo. Configure here.