Skip to content

Commit

Permalink
Clear all timeout on destroy and close (nodejs#2535)
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <hello@matteocollina.com>
  • Loading branch information
mcollina authored Dec 23, 2023
1 parent f51f917 commit a1a8136
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class Agent extends DispatcherBase {
async [kClose] () {
const closePromises = []
for (const client of this[kClients].values()) {
if (client[kDeleteScheduled]) {
clearTimeout(client[kDeleteScheduled])
}
closePromises.push(client.close())
}
this[kClients].clear()
Expand All @@ -120,6 +123,9 @@ class Agent extends DispatcherBase {
async [kDestroy] (err) {
const destroyPromises = []
for (const client of this[kClients].values()) {
if (client[kDeleteScheduled]) {
clearTimeout(client[kDeleteScheduled])
}
destroyPromises.push(client.destroy(err))
}
this[kClients].clear()
Expand Down

0 comments on commit a1a8136

Please sign in to comment.