Skip to content

Commit

Permalink
Fix transport.once listener for timeout event
Browse files Browse the repository at this point in the history
  • Loading branch information
aliendrew committed Nov 7, 2023
1 parent 4aa603a commit bd7ef81
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ class Client extends EventEmitter {
this.destroy();
transport.server.clients.delete(this);
});
const timeoutHandler = () => {
if (transport instanceof HttpTransport)
transport.off('timeout', timeoutHandler);
transport.once('timeout', () => {
abortable.abort('Request Timeout');
};
transport.once('timeout', timeoutHandler);
});
abortable.once('aborted', (error) => {
if (transport instanceof HttpTransport) {
error.code = error.httpCode = 408;
Expand Down

0 comments on commit bd7ef81

Please sign in to comment.