Skip to content

[diagnostics_channel] tracingChannel.traceCallback incorrect types #50996

@Semigradsky

Description

@Semigradsky

Affected URL(s)

https://nodejs.org/docs/latest-v18.x/api/diagnostics_channel.html#tracingchanneltracecallbackfn-position-context-thisarg-args

Description of the problem

tracingChannel.traceCallback(fn[, position[, context[, thisArg[, ...args]]]]) - almost all args are marked as optional but it can't be called only with the first argument.

const callback = ArrayPrototypeAt(args, position);
validateFunction(callback, 'callback');

^ callback is required, so we need to call it like this:

channels.traceCallback(
	function (callback) {
		// Do something
		callback(null, 'result');
	},
	undefined, // position - `-1` by default
	undefined, // context - `{}` by default
	undefined, // thisArg - any value
	callback,
)

So all arguments are required but some can be undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnostics_channelIssues and PRs related to diagnostics channeldocIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions