Skip to content

Commit 7eceaa3

Browse files
author
Kartik Raj
committed
Reject deferred on dispose
1 parent f531b28 commit 7eceaa3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/client/common/process/rawProcessApis.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export function plainExec(
102102
dispose: () => {
103103
if (!proc.killed) {
104104
proc.kill();
105+
deferred.reject(new Error('Process was killed'));
105106
}
106107
},
107108
};

src/client/common/utils/async.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ class DeferredImpl<T> implements Deferred<T> {
5050
}
5151

5252
public resolve(_value: T | PromiseLike<T>) {
53+
if (this.completed) {
54+
return;
55+
}
5356
this._resolve.apply(this.scope ? this.scope : this, [_value]);
5457
this._resolved = true;
5558
}
5659

5760
public reject(_reason?: string | Error | Record<string, unknown>) {
61+
if (this.completed) {
62+
return;
63+
}
5864
this._reject.apply(this.scope ? this.scope : this, [_reason]);
5965
this._rejected = true;
6066
}

0 commit comments

Comments
 (0)