Skip to content

Commit c02c91c

Browse files
authored
Fixes #1628: Cancellation after first convert is not considered (#1629)
1 parent df05883 commit c02c91c

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

client/src/common/utils/async.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ export async function map<P, C>(items: ReadonlyArray<P>, func: (item: P) => C, t
261261
}
262262
index = await new Promise((resolve) => {
263263
RAL().timer.setImmediate(() => {
264-
resolve(convertBatch(index));
264+
if (token !== undefined && token.isCancellationRequested) {
265+
resolve(-1);
266+
} else {
267+
resolve(convertBatch(index));
268+
}
265269
});
266270
});
267271
}
@@ -292,7 +296,11 @@ export async function mapAsync<P, C>(items: ReadonlyArray<P>, func: (item: P, to
292296
}
293297
index = await new Promise((resolve) => {
294298
RAL().timer.setImmediate(() => {
295-
resolve(convertBatch(index));
299+
if (token !== undefined && token.isCancellationRequested) {
300+
resolve(-1);
301+
} else {
302+
resolve(convertBatch(index));
303+
}
296304
});
297305
});
298306
}
@@ -323,7 +331,11 @@ export async function forEach<P>(items: ReadonlyArray<P>, func: (item: P) => voi
323331
}
324332
index = await new Promise((resolve) => {
325333
RAL().timer.setImmediate(() => {
326-
resolve(runBatch(index));
334+
if (token !== undefined && token.isCancellationRequested) {
335+
resolve(-1);
336+
} else {
337+
resolve(runBatch(index));
338+
}
327339
});
328340
});
329341
}

0 commit comments

Comments
 (0)