Skip to content

Commit 74c0308

Browse files
committed
feat: handle already aborted signals in cancellation token
1 parent beabb66 commit 74c0308

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export function convertAbortSignalToCancellationToken(
3737
listener(null);
3838
}
3939
};
40+
41+
// If the signal is already aborted, invoke the listener immediately
42+
if (signal.aborted) {
43+
// Use setTimeout to make it asynchronous, mimicking VS Code's behavior
44+
setTimeout(handler, 0);
45+
}
46+
4047
signal.addEventListener("abort", handler);
4148
const disposable = new Disposable(() =>
4249
signal.removeEventListener("abort", handler),

0 commit comments

Comments
 (0)