Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
diagnostics_channel: Avoid wrapping with no subscribers
  • Loading branch information
Stephen Belanger committed Nov 9, 2022
commit 789d1e072eed046a209c4ac3956b3f45847bd05a
3 changes: 3 additions & 0 deletions lib/diagnostics_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class TracingChannel {
}

traceSync(fn, ctx = {}, thisArg, ...args) {
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { start, end, error } = this.#channels;
start.publish(ctx);
try {
Expand All @@ -198,6 +199,7 @@ class TracingChannel {
}

tracePromise(fn, ctx = {}, thisArg, ...args) {
Comment thread
mcollina marked this conversation as resolved.
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { asyncEnd, start, end, error } = this.#channels;
start.publish(ctx);

Expand Down Expand Up @@ -227,6 +229,7 @@ class TracingChannel {
}

traceCallback(fn, position = 0, ctx = {}, thisArg, ...args) {
if (!this.hasSubscribers) return ReflectApply(fn, thisArg, args);
const { start, end, asyncEnd, error } = this.#channels;
start.publish(ctx);

Expand Down