Skip to content

Commit 5431221

Browse files
committed
Fixes ProducerConsumer: cannot produce after final value has been set
1 parent fb3ad8d commit 5431221

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/vs/base/common/async.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,11 +2430,16 @@ export class AsyncIterableProducer<T> implements AsyncIterable<T> {
24302430
}
24312431

24322432
private _finishOk(): void {
2433-
this._producerConsumer.produceFinal({ ok: true, value: { done: true, value: undefined } });
2433+
if (!this._producerConsumer.hasFinalValue) {
2434+
this._producerConsumer.produceFinal({ ok: true, value: { done: true, value: undefined } });
2435+
}
24342436
}
24352437

24362438
private _finishError(error: Error): void {
2437-
this._producerConsumer.produceFinal({ ok: false, error: error });
2439+
if (!this._producerConsumer.hasFinalValue) {
2440+
this._producerConsumer.produceFinal({ ok: false, error: error });
2441+
}
2442+
// Warning: this can cause to dropped errors.
24382443
}
24392444

24402445
private readonly _iterator: AsyncIterator<T, void, void> = {

0 commit comments

Comments
 (0)