| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 539bee4 commit 838179b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -853,7 +853,7 @@ channels.tracePromise(async () => { | |||
| 853 | 853 | }); | |
| 854 | 854 | ``` | |
| 855 | 855 | ||
| 856 | - #### `tracingChannel.traceCallback(fn[, position[, context[, thisArg[, ...args]]]])` | ||
| 856 | + #### `tracingChannel.traceCallback(fn, position, context, thisArg, ...args)` | ||
| 857 | 857 | ||
| 858 | 858 | <!-- YAML | |
| 859 | 859 | added: | |
@@ -864,23 +864,23 @@ added: | |||
| 864 | 864 | ||
| 865 | 865 | * `fn` {Function} callback using function to wrap a trace around | |
| 866 | 866 | * `position` {number} Zero-indexed argument position of expected callback | |
| 867 | - * `context` {Object} Shared object to correlate trace events through | ||
| 867 | + (defaults to last argument if `undefined` is passed) | ||
| 868 | + * `context` {Object} Shared object to correlate trace events through (defaults | ||
| 869 | + to `{}` if `undefined` is passed) | ||
| 868 | 870 | * `thisArg` {any} The receiver to be used for the function call | |
| 869 | - * `...args` {any} Optional arguments to pass to the function | ||
| 871 | + * `...args` {any} arguments to pass to the function (must include the callback) | ||
| 870 | 872 | * Returns: {any} The return value of the given function | |
| 871 | 873 | ||
| 872 | - Trace a callback-receiving function call. This will always produce a | ||
| 874 | + Trace a callback-receiving function call. The callback is expected to follow | ||
| 875 | + the error as first arg convention typically used. This will always produce a | ||
| 873 | 876 | [`start` event][] and [`end` event][] around the synchronous portion of the | |
| 874 | 877 | function execution, and will produce a [`asyncStart` event][] and | |
| 875 | 878 | [`asyncEnd` event][] around the callback execution. It may also produce an | |
| 876 | - [`error` event][] if the given function throws an error or the returned | ||
| 877 | - promise rejects. This will run the given function using | ||
| 879 | + [`error` event][] if the given function throws or the first argument passed to | ||
| 880 | + the callback is set. This will run the given function using | ||
| 878 | 881 | [`channel.runStores(context, ...)`][] on the `start` channel which ensures all | |
| 879 | 882 | events should have any bound stores set to match this trace context. | |
| 880 | 883 | ||
| 881 | - The `position` will be -1 by default to indicate the final argument should | ||
| 882 | - be used as the callback. | ||
| 883 | - | ||
| 884 | 884 | ```mjs | |
| 885 | 885 | import diagnostics_channel from 'node:diagnostics_channel'; | |
| 886 | 886 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,9 +371,7 @@ class TracingChannel { | |||
| 371 | 371 | // Using runStores here enables manual context failure recovery | |
| 372 | 372 | asyncStart.runStores(context, () => { | |
| 373 | 373 | try { | |
| 374 | - if (callback) { | ||
| 375 | - return ReflectApply(callback, this, arguments); | ||
| 376 | - } | ||
| 374 | + return ReflectApply(callback, this, arguments); | ||
| 377 | 375 | } finally { | |
| 378 | 376 | asyncEnd.publish(context); | |
| 379 | 377 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments