Updated closing logic
This commit is contained in:
@ -110,12 +110,13 @@ class Connection {
|
||||
}
|
||||
|
||||
// TODO: write a better closing logic
|
||||
close () {
|
||||
close (callback = () => {}) {
|
||||
debug('Closing connection', this.id)
|
||||
if (this._openRequests > 0) {
|
||||
setTimeout(() => this.close(), 1000)
|
||||
setTimeout(() => this.close(callback), 1000)
|
||||
} else {
|
||||
this._agent.destroy()
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user