Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Feb 4, 2022
1 parent 893e88b commit fc717a8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ function on(emitter, event, options) {
const queue = new FixedQueue();
let resume = null;
let error = null;
let errored = false

const signal = options?.signal;
validateAbortSignal(signal, 'options.signal');
Expand All @@ -1034,6 +1035,8 @@ function on(emitter, event, options) {

function errorHandler (err) {
error = err;
errored = true;

if (resume) {
resume(Promise.reject(err));
resume = null;
Expand All @@ -1057,13 +1060,13 @@ function on(emitter, event, options) {
try {
while (true) {
while (!queue.isEmpty()) {
if (error) {
if (errored) {
throw error;
}
yield queue.shift();
}

if (error) {
if (errored) {
throw error;
}

Expand Down

0 comments on commit fc717a8

Please sign in to comment.