fix: early return on cancellation

This commit is contained in:
AkatQuas 2021-09-07 16:28:21 +08:00
parent 1e1025fc96
commit e4fb11a1e7
3 changed files with 3 additions and 0 deletions

View file

@ -23,6 +23,7 @@ export function runSafeAsync<T>(runtime: RuntimeEnvironment, func: () => Thenabl
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
return;
}
return func().then(result => {
if (token.isCancellationRequested) {

View file

@ -23,6 +23,7 @@ export function runSafe<T>(runtime: RuntimeEnvironment, func: () => Thenable<T>,
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
return;
}
return func().then(result => {
if (token.isCancellationRequested) {

View file

@ -23,6 +23,7 @@ export function runSafeAsync<T>(runtime: RuntimeEnvironment, func: () => Thenabl
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
return;
}
return func().then(result => {
if (token.isCancellationRequested) {