Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/client/http-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ class HTTPTracker extends Tracker {
this.destroyed = true
clearInterval(this.interval)

let timeout

// If there are no pending requests, destroy immediately.
if (this.cleanupFns.length === 0) return destroyCleanup()

// Otherwise, wait a short time for pending requests to complete, then force
// destroy them.
let timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)
timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)

// But, if all pending requests complete before the timeout fires, do cleanup
// right away.
Expand Down
4 changes: 3 additions & 1 deletion lib/client/udp-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class UDPTracker extends Tracker {
this.destroyed = true
clearInterval(this.interval)

let timeout

// If there are no pending requests, destroy immediately.
if (this.cleanupFns.length === 0) return destroyCleanup()

// Otherwise, wait a short time for pending requests to complete, then force
// destroy them.
let timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)
timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)

// But, if all pending requests complete before the timeout fires, do cleanup
// right away.
Expand Down
4 changes: 3 additions & 1 deletion lib/client/websocket-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ class WebSocketTracker extends Tracker {
socket.on('error', noop) // ignore all future errors
socket.once('close', cb)

let timeout

// If there is no data response expected, destroy immediately.
if (!this.expectingResponse) return destroyCleanup()

// Otherwise, wait a short time for potential responses to come in from the
// server, then force close the socket.
let timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)
timeout = setTimeout(destroyCleanup, common.DESTROY_TIMEOUT)

// But, if a response comes from the server before the timeout fires, do cleanup
// right away.
Expand Down