Skip to content

Commit

Permalink
fix(http-captor): 'data' might not be the first listener attached
Browse files Browse the repository at this point in the history
  • Loading branch information
fredriklindberg committed Jun 24, 2021
1 parent e2d61eb commit 714c726
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/http-captor.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ class HttpCaptor {
}
};

this._request.once('newListener', (event, listener) => {
const onListener = (event, listener) => {
if (event === 'data') {
this._request.off('newListener', onListener);
this._request.on('data', handleData);
}
});
};
this._request.on('newListener', onListener);
this._request.once('end', done);
this._request.once('error', done);
});
Expand Down

0 comments on commit 714c726

Please sign in to comment.