Skip to content

Commit 3381557

Browse files
use setImmediate to let all cancellation listeners happen. This works because setImmediate will run on the next event loop, while the cancellation listeners are on the current loop (#4530)
1 parent 232c28e commit 3381557

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,12 @@ export function createCombinedCancellationToken(...tokens: (vscode.CancellationT
14131413
disposables.push(combinedSource);
14141414

14151415
combinedSource.token.onCancellationRequested(() => {
1416-
disposables.forEach(d => d.dispose());
1416+
// Defer disposal to allow all listeners to be notified first
1417+
setImmediate(() => {
1418+
disposables.forEach(d => {
1419+
d.dispose();
1420+
});
1421+
});
14171422
});
14181423

14191424
return combinedSource.token;

0 commit comments

Comments
 (0)