Skip to content

Commit

Permalink
Avoid probes interval blocking shutdown
Browse files Browse the repository at this point in the history
The probes instance starts an interval timer on initialisation.
By default, timers cause the Node.js engine to await their
completion on shutdown -- which, this being an interval timer, is
never actually completed. (See #418)

We fixed this in the past by implementing `Appsignal.stop`, which
clears the interval. But a preferable solution is to mark the
probes' interval as `.unref()`, telling the Node.js engine that it
does not need to be awaited.
  • Loading branch information
unflxw committed Sep 5, 2024
1 parent 946fbb4 commit 416e043
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/probes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class BaseProbeRunner extends EventEmitter implements ProbeRunner {
public register(name: string, fn: () => void): void {
this.#timers.set(
name,
setInterval(() => this.emit(name), 60 * 1000)
setInterval(() => this.emit(name), 60 * 1000).unref()
)

this.removeAllListeners(name)
Expand Down

0 comments on commit 416e043

Please sign in to comment.