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 and crysmags committed Feb 27, 2024
1 parent 25a26b3 commit 9c40c26
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 9c40c26

Please sign in to comment.