Skip to content

feat: Add AbortSignal support for cancelling long-running operations#153

Open
sarthakNITT wants to merge 2 commits into
limrun-inc:mainfrom
sarthakNITT:abortSignal
Open

feat: Add AbortSignal support for cancelling long-running operations#153
sarthakNITT wants to merge 2 commits into
limrun-inc:mainfrom
sarthakNITT:abortSignal

Conversation

@sarthakNITT

@sarthakNITT sarthakNITT commented Jun 14, 2026

Copy link
Copy Markdown

Description

Fixes #152

This PR adds AbortSignal support to the iOS SDK, allowing consumers to manually cancel long-running requests like installApp and performActions using a standard AbortController without having to wait for the client-side timeout to expire.

Changes Made

  • AppInstallationOptions: Added signal?: AbortSignal property.
  • InstanceClient: Updated performActions signature to accept an optional signal.
  • sendRequest:
    • Now accepts an optional signal?: AbortSignal parameter.
    • Implements an abort event listener that immediately calls clearTimeout, removes the request ID from the pendingRequests Map, and rejects the promise with an AbortError.
    • Cleans up event listeners when the promise resolves or rejects normally to avoid memory leaks.

Note

Low Risk
Client-only cancellation of in-flight requests; does not change server protocol or security-sensitive paths.

Overview
Adds optional AbortSignal support so callers can cancel long-running WebSocket requests without waiting for the client timeout.

sendRequest now accepts an optional signal: it rejects immediately with AbortError if already aborted, registers a one-shot abort listener that clears the request timeout, drops the pending entry, and rejects; resolve/reject paths remove the listener to avoid leaks.

installApp exposes options.signal via AppInstallationOptions; performActions accepts options.signal and 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.

Copilot AI review requested due to automatic review settings June 14, 2026 09:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AppInstallationOptions and performActions options to accept an optional AbortSignal.
  • Update sendRequest to reject with an AbortError when aborted and to clean up pending requests.
  • Propagate options.signal into calls that use sendRequest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ios-client.ts Outdated
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 thread src/ios-client.ts Outdated
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 thread src/ios-client.ts Outdated
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);

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/ios-client.ts Outdated
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.

Feature: Add AbortSignal support to cancel long-running operations

2 participants