Skip to content

Commit

Permalink
fix: Handle socket timeout to prevent connections from leaking (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimoravcik authored Feb 20, 2023
1 parent dbf0eab commit a460ad8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ export class Server extends EventEmitter {

this.connections.delete(unique);
});
// We have to manually destroy the socket if it timeouts.
// This will prevent connections from leaking and close them properly.
socket.on('timeout', () => {
socket.destroy();
});
}

/**
Expand Down

0 comments on commit a460ad8

Please sign in to comment.