Diagnostics Channel#

History
VersionChanges
v19.2.0, v18.13.0

diagnostics_channel is now Stable.

v15.1.0, v14.17.0

Added in: v15.1.0, v14.17.0

Stability: 2 - Stable

Source Code:lib/diagnostics_channel.js

Thenode:diagnostics_channel module provides an API to create named channelsto report arbitrary message data for diagnostics purposes.

It can be accessed using:

import diagnostics_channelfrom'node:diagnostics_channel';const diagnostics_channel =require('node:diagnostics_channel');

It is intended that a module writer wanting to report diagnostics messageswill create one or many top-level channels to report messages through.Channels may also be acquired at runtime but it is not encourageddue to the additional overhead of doing so. Channels may be exported forconvenience, but as long as the name is known it can be acquired anywhere.

If you intend for your module to produce diagnostics data for others toconsume it is recommended that you include documentation of what namedchannels are used along with the shape of the message data. Channel namesshould generally include the module name to avoid collisions with data fromother modules.

Public API#

Overview#

Following is a simple overview of the public API.

import diagnostics_channelfrom'node:diagnostics_channel';// Get a reusable channel objectconst channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}// Subscribe to the channeldiagnostics_channel.subscribe('my-channel', onMessage);// Check if the channel has an active subscriberif (channel.hasSubscribers) {// Publish data to the channel  channel.publish({some:'data',  });}// Unsubscribe from the channeldiagnostics_channel.unsubscribe('my-channel', onMessage);const diagnostics_channel =require('node:diagnostics_channel');// Get a reusable channel objectconst channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}// Subscribe to the channeldiagnostics_channel.subscribe('my-channel', onMessage);// Check if the channel has an active subscriberif (channel.hasSubscribers) {// Publish data to the channel  channel.publish({some:'data',  });}// Unsubscribe from the channeldiagnostics_channel.unsubscribe('my-channel', onMessage);
diagnostics_channel.hasSubscribers(name)#
Added in: v15.1.0, v14.17.0

Check if there are active subscribers to the named channel. This is helpful ifthe message you want to send might be expensive to prepare.

This API is optional but helpful when trying to publish messages from veryperformance-sensitive code.

import diagnostics_channelfrom'node:diagnostics_channel';if (diagnostics_channel.hasSubscribers('my-channel')) {// There are subscribers, prepare and publish message}const diagnostics_channel =require('node:diagnostics_channel');if (diagnostics_channel.hasSubscribers('my-channel')) {// There are subscribers, prepare and publish message}
diagnostics_channel.channel(name)#
Added in: v15.1.0, v14.17.0

This is the primary entry-point for anyone wanting to publish to a namedchannel. It produces a channel object which is optimized to reduce overhead atpublish time as much as possible.

import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');
diagnostics_channel.subscribe(name, onMessage)#
Added in: v18.7.0, v16.17.0

Register a message handler to subscribe to this channel. This message handlerwill be run synchronously whenever a message is published to the channel. Anyerrors thrown in the message handler will trigger an'uncaughtException'.

import diagnostics_channelfrom'node:diagnostics_channel';diagnostics_channel.subscribe('my-channel',(message, name) => {// Received data});const diagnostics_channel =require('node:diagnostics_channel');diagnostics_channel.subscribe('my-channel',(message, name) => {// Received data});
diagnostics_channel.unsubscribe(name, onMessage)#
Added in: v18.7.0, v16.17.0

Remove a message handler previously registered to this channel withdiagnostics_channel.subscribe(name, onMessage).

import diagnostics_channelfrom'node:diagnostics_channel';functiononMessage(message, name) {// Received data}diagnostics_channel.subscribe('my-channel', onMessage);diagnostics_channel.unsubscribe('my-channel', onMessage);const diagnostics_channel =require('node:diagnostics_channel');functiononMessage(message, name) {// Received data}diagnostics_channel.subscribe('my-channel', onMessage);diagnostics_channel.unsubscribe('my-channel', onMessage);
diagnostics_channel.tracingChannel(nameOrChannels)#
Added in: v19.9.0, v18.19.0

Stability: 1 - Experimental

Creates aTracingChannel wrapper for the givenTracingChannel Channels. If a name is given, the corresponding tracingchannels will be created in the form oftracing:${name}:${eventType} whereeventType corresponds to the types ofTracingChannel Channels.

import diagnostics_channelfrom'node:diagnostics_channel';const channelsByName = diagnostics_channel.tracingChannel('my-channel');// or...const channelsByCollection = diagnostics_channel.tracingChannel({start: diagnostics_channel.channel('tracing:my-channel:start'),end: diagnostics_channel.channel('tracing:my-channel:end'),asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),error: diagnostics_channel.channel('tracing:my-channel:error'),});const diagnostics_channel =require('node:diagnostics_channel');const channelsByName = diagnostics_channel.tracingChannel('my-channel');// or...const channelsByCollection = diagnostics_channel.tracingChannel({start: diagnostics_channel.channel('tracing:my-channel:start'),end: diagnostics_channel.channel('tracing:my-channel:end'),asyncStart: diagnostics_channel.channel('tracing:my-channel:asyncStart'),asyncEnd: diagnostics_channel.channel('tracing:my-channel:asyncEnd'),error: diagnostics_channel.channel('tracing:my-channel:error'),});

Class:Channel#

Added in: v15.1.0, v14.17.0

The classChannel represents an individual named channel within the datapipeline. It is used to track subscribers and to publish messages when thereare subscribers present. It exists as a separate object to avoid channellookups at publish time, enabling very fast publish speeds and allowingfor heavy use while incurring very minimal cost. Channels are created withdiagnostics_channel.channel(name), constructing a channel directlywithnew Channel(name) is not supported.

channel.hasSubscribers#
Added in: v15.1.0, v14.17.0
  • Returns:<boolean> If there are active subscribers

Check if there are active subscribers to this channel. This is helpful ifthe message you want to send might be expensive to prepare.

This API is optional but helpful when trying to publish messages from veryperformance-sensitive code.

import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');if (channel.hasSubscribers) {// There are subscribers, prepare and publish message}const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');if (channel.hasSubscribers) {// There are subscribers, prepare and publish message}
channel.publish(message)#
Added in: v15.1.0, v14.17.0
  • message<any> The message to send to the channel subscribers

Publish a message to any subscribers to the channel. This will triggermessage handlers synchronously so they will execute within the same context.

import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');channel.publish({some:'message',});const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');channel.publish({some:'message',});
channel.subscribe(onMessage)#
History
VersionChanges
v24.8.0, v22.20.0

Deprecation revoked.

v18.7.0, v16.17.0

Documentation-only deprecation.

v15.1.0, v14.17.0

Added in: v15.1.0, v14.17.0

Register a message handler to subscribe to this channel. This message handlerwill be run synchronously whenever a message is published to the channel. Anyerrors thrown in the message handler will trigger an'uncaughtException'.

import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');channel.subscribe((message, name) => {// Received data});const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');channel.subscribe((message, name) => {// Received data});
channel.unsubscribe(onMessage)#
History
VersionChanges
v24.8.0, v22.20.0

Deprecation revoked.

v18.7.0, v16.17.0

Documentation-only deprecation.

v17.1.0, v16.14.0, v14.19.0

Added return value. Added to channels without subscribers.

v15.1.0, v14.17.0

Added in: v15.1.0, v14.17.0

  • onMessage<Function> The previous subscribed handler to remove
  • Returns:<boolean>true if the handler was found,false otherwise.

Remove a message handler previously registered to this channel withchannel.subscribe(onMessage).

import diagnostics_channelfrom'node:diagnostics_channel';const channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}channel.subscribe(onMessage);channel.unsubscribe(onMessage);const diagnostics_channel =require('node:diagnostics_channel');const channel = diagnostics_channel.channel('my-channel');functiononMessage(message, name) {// Received data}channel.subscribe(onMessage);channel.unsubscribe(onMessage);
channel.bindStore(store[, transform])#
Added in: v19.9.0, v18.19.0

Stability: 1 - Experimental

Whenchannel.runStores(context, ...) is called, the given context datawill be applied to any store bound to the channel. If the store has already beenbound the previoustransform function will be replaced with the new one.Thetransform function may be omitted to set the given context data as thecontext directly.

import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(data) => {return { data };});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(data) => {return { data };});
channel.unbindStore(store)#
Added in: v19.9.0, v18.19.0

Stability: 1 - Experimental

Remove a message handler previously registered to this channel withchannel.bindStore(store).

import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store);channel.unbindStore(store);const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store);channel.unbindStore(store);
channel.runStores(context, fn[, thisArg[, ...args]])#
Added in: v19.9.0, v18.19.0

Stability: 1 - Experimental

  • context<any> Message to send to subscribers and bind to stores
  • fn<Function> Handler to run within the entered storage context
  • thisArg<any> The receiver to be used for the function call.
  • ...args<any> Optional arguments to pass to the function.

Applies the given data to any AsyncLocalStorage instances bound to the channelfor the duration of the given function, then publishes to the channel withinthe scope of that data is applied to the stores.

If a transform function was given tochannel.bindStore(store) it will beapplied to transform the message data before it becomes the context value forthe store. The prior storage context is accessible from within the transformfunction in cases where context linking is required.

The context applied to the store should be accessible in any async code whichcontinues from execution which began during the given function, howeverthere are some situations in whichcontext loss may occur.

import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(message) => {const parent = store.getStore();returnnewSpan(message, parent);});channel.runStores({some:'message' },() => {  store.getStore();// Span({ some: 'message' })});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const store =newAsyncLocalStorage();const channel = diagnostics_channel.channel('my-channel');channel.bindStore(store,(message) => {const parent = store.getStore();returnnewSpan(message, parent);});channel.runStores({some:'message' },() => {  store.getStore();// Span({ some: 'message' })});

Class:TracingChannel#

Added in: v19.9.0, v18.19.0

Stability: 1 - Experimental

The classTracingChannel is a collection ofTracingChannel Channels whichtogether express a single traceable action. It is used to formalize andsimplify the process of producing events for tracing application flow.diagnostics_channel.tracingChannel() is used to construct aTracingChannel. As withChannel it is recommended to create and reuse asingleTracingChannel at the top-level of the file rather than creating themdynamically.

tracingChannel.subscribe(subscribers)#
Added in: v19.9.0, v18.19.0

Helper to subscribe a collection of functions to the corresponding channels.This is the same as callingchannel.subscribe(onMessage) on each channelindividually.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.subscribe({start(message) {// Handle start message  },end(message) {// Handle end message  },asyncStart(message) {// Handle asyncStart message  },asyncEnd(message) {// Handle asyncEnd message  },error(message) {// Handle error message  },});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.subscribe({start(message) {// Handle start message  },end(message) {// Handle end message  },asyncStart(message) {// Handle asyncStart message  },asyncEnd(message) {// Handle asyncEnd message  },error(message) {// Handle error message  },});
tracingChannel.unsubscribe(subscribers)#
Added in: v19.9.0, v18.19.0

Helper to unsubscribe a collection of functions from the corresponding channels.This is the same as callingchannel.unsubscribe(onMessage) on each channelindividually.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.unsubscribe({start(message) {// Handle start message  },end(message) {// Handle end message  },asyncStart(message) {// Handle asyncStart message  },asyncEnd(message) {// Handle asyncEnd message  },error(message) {// Handle error message  },});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.unsubscribe({start(message) {// Handle start message  },end(message) {// Handle end message  },asyncStart(message) {// Handle asyncStart message  },asyncEnd(message) {// Handle asyncEnd message  },error(message) {// Handle error message  },});
tracingChannel.traceSync(fn[, context[, thisArg[, ...args]]])#
Added in: v19.9.0, v18.19.0
  • fn<Function> Function to wrap a trace around
  • context<Object> Shared object to correlate events through
  • thisArg<any> The receiver to be used for the function call
  • ...args<any> Optional arguments to pass to the function
  • Returns:<any> The return value of the given function

Trace a synchronous function call. This will always produce astart eventandend event around the execution and may produce anerror eventif the given function throws an error. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.

To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceSync(() => {// Do something}, {some:'thing',});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceSync(() => {// Do something}, {some:'thing',});
tracingChannel.tracePromise(fn[, context[, thisArg[, ...args]]])#
Added in: v19.9.0, v18.19.0
  • fn<Function> Promise-returning function to wrap a trace around
  • context<Object> Shared object to correlate trace events through
  • thisArg<any> The receiver to be used for the function call
  • ...args<any> Optional arguments to pass to the function
  • Returns:<Promise> Chained from promise returned by the given function

Trace a promise-returning function call. This will always produce astart event andend event around the synchronous portion of thefunction execution, and will produce anasyncStart event andasyncEnd event when a promise continuation is reached. It may alsoproduce anerror event if the given function throws an error or thereturned promise rejects. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.

To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.tracePromise(async () => {// Do something}, {some:'thing',});const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.tracePromise(async () => {// Do something}, {some:'thing',});
tracingChannel.traceCallback(fn[, position[, context[, thisArg[, ...args]]]])#
Added in: v19.9.0, v18.19.0
  • fn<Function> callback using function to wrap a trace around
  • position<number> Zero-indexed argument position of expected callback(defaults to last argument ifundefined is passed)
  • context<Object> Shared object to correlate trace events through (defaultsto{} ifundefined is passed)
  • thisArg<any> The receiver to be used for the function call
  • ...args<any> arguments to pass to the function (must include the callback)
  • Returns:<any> The return value of the given function

Trace a callback-receiving function call. The callback is expected to followthe error as first arg convention typically used. This will always produce astart event andend event around the synchronous portion of thefunction execution, and will produce aasyncStart event andasyncEnd event around the callback execution. It may also produce anerror event if the given function throws or the first argument passed tothe callback is set. This will run the given function usingchannel.runStores(context, ...) on thestart channel which ensures allevents should have any bound stores set to match this trace context.

To ensure only correct trace graphs are formed, events will only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins will not receive future events from that trace,only future traces will be seen.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceCallback((arg1, callback) => {// Do somethingcallback(null,'result');},1, {some:'thing',}, thisArg, arg1, callback);const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');channels.traceCallback((arg1, callback) => {// Do somethingcallback(null,'result');},1, {some:'thing',}, thisArg, arg1, callback);

The callback will also be run withchannel.runStores(context, ...) whichenables context loss recovery in some cases.

import diagnostics_channelfrom'node:diagnostics_channel';import {AsyncLocalStorage }from'node:async_hooks';const channels = diagnostics_channel.tracingChannel('my-channel');const myStore =newAsyncLocalStorage();// The start channel sets the initial store data to something// and stores that store data value on the trace context objectchannels.start.bindStore(myStore,(data) => {const span =newSpan(data);  data.span = span;return span;});// Then asyncStart can restore from that data it stored previouslychannels.asyncStart.bindStore(myStore,(data) => {return data.span;});const diagnostics_channel =require('node:diagnostics_channel');const {AsyncLocalStorage } =require('node:async_hooks');const channels = diagnostics_channel.tracingChannel('my-channel');const myStore =newAsyncLocalStorage();// The start channel sets the initial store data to something// and stores that store data value on the trace context objectchannels.start.bindStore(myStore,(data) => {const span =newSpan(data);  data.span = span;return span;});// Then asyncStart can restore from that data it stored previouslychannels.asyncStart.bindStore(myStore,(data) => {return data.span;});
tracingChannel.hasSubscribers#
Added in: v22.0.0, v20.13.0
  • Returns:<boolean>true if any of the individual channels has a subscriber,false if not.

This is a helper method available on aTracingChannel instance to check ifany of theTracingChannel Channels have subscribers. Atrue is returned ifany of them have at least one subscriber, afalse is returned otherwise.

import diagnostics_channelfrom'node:diagnostics_channel';const channels = diagnostics_channel.tracingChannel('my-channel');if (channels.hasSubscribers) {// Do something}const diagnostics_channel =require('node:diagnostics_channel');const channels = diagnostics_channel.tracingChannel('my-channel');if (channels.hasSubscribers) {// Do something}

TracingChannel Channels#

A TracingChannel is a collection of several diagnostics_channels representingspecific points in the execution lifecycle of a single traceable action. Thebehavior is split into five diagnostics_channels consisting ofstart,end,asyncStart,asyncEnd, anderror. A single traceable action willshare the same event object between all events, this can be helpful formanaging correlation through a weakmap.

These event objects will be extended withresult orerror values whenthe task "completes". In the case of a synchronous task theresult will bethe return value and theerror will be anything thrown from the function.With callback-based async functions theresult will be the second argumentof the callback while theerror will either be a thrown error visible in theend event or the first callback argument in either of theasyncStart orasyncEnd events.

To ensure only correct trace graphs are formed, events should only be publishedif subscribers are present prior to starting the trace. Subscriptions which areadded after the trace begins should not receive future events from that trace,only future traces will be seen.

Tracing channels should follow a naming pattern of:

  • tracing:module.class.method:start ortracing:module.function:start
  • tracing:module.class.method:end ortracing:module.function:end
  • tracing:module.class.method:asyncStart ortracing:module.function:asyncStart
  • tracing:module.class.method:asyncEnd ortracing:module.function:asyncEnd
  • tracing:module.class.method:error ortracing:module.function:error
start(event)#
  • Name:tracing:${name}:start

Thestart event represents the point at which a function is called. At thispoint the event data may contain function arguments or anything else availableat the very start of the execution of the function.

end(event)#
  • Name:tracing:${name}:end

Theend event represents the point at which a function call returns a value.In the case of an async function this is when the promise returned not when thefunction itself makes a return statement internally. At this point, if thetraced function was synchronous theresult field will be set to the returnvalue of the function. Alternatively, theerror field may be present torepresent any thrown errors.

It is recommended to listen specifically to theerror event to track errorsas it may be possible for a traceable action to produce multiple errors. Forexample, an async task which fails may be started internally before the syncpart of the task then throws an error.

asyncStart(event)#
  • Name:tracing:${name}:asyncStart

TheasyncStart event represents the callback or continuation of a traceablefunction being reached. At this point things like callback arguments may beavailable, or anything else expressing the "result" of the action.

For callbacks-based functions, the first argument of the callback will beassigned to theerror field, if notundefined ornull, and the secondargument will be assigned to theresult field.

For promises, the argument to theresolve path will be assigned toresultor the argument to thereject path will be assign toerror.

It is recommended to listen specifically to theerror event to track errorsas it may be possible for a traceable action to produce multiple errors. Forexample, an async task which fails may be started internally before the syncpart of the task then throws an error.

asyncEnd(event)#
  • Name:tracing:${name}:asyncEnd

TheasyncEnd event represents the callback of an asynchronous functionreturning. It's not likely event data will change after theasyncStart event,however it may be useful to see the point where the callback completes.

error(event)#
  • Name:tracing:${name}:error

Theerror event represents any error produced by the traceable functioneither synchronously or asynchronously. If an error is thrown in thesynchronous portion of the traced function the error will be assigned to theerror field of the event and theerror event will be triggered. If an erroris received asynchronously through a callback or promise rejection it will alsobe assigned to theerror field of the event and trigger theerror event.

It is possible for a single traceable function call to produce errors multipletimes so this should be considered when consuming this event. For example, ifanother async task is triggered internally which fails and then the sync partof the function then throws and error twoerror events will be emitted, onefor the sync error and one for the async error.

Built-in Channels#

Console#

Stability: 1 - Experimental

Event:'console.log'#

Emitted whenconsole.log() is called. Receives and array of the argumentspassed toconsole.log().

Event:'console.info'#

Emitted whenconsole.info() is called. Receives and array of the argumentspassed toconsole.info().

Event:'console.debug'#

Emitted whenconsole.debug() is called. Receives and array of the argumentspassed toconsole.debug().

Event:'console.warn'#

Emitted whenconsole.warn() is called. Receives and array of the argumentspassed toconsole.warn().

Event:'console.error'#

Emitted whenconsole.error() is called. Receives and array of the argumentspassed toconsole.error().

HTTP#

Stability: 1 - Experimental

Event:'http.client.request.created'#

Emitted when client creates a request object.Unlikehttp.client.request.start, this event is emitted before the request has been sent.

Event:'http.client.request.start'#

Emitted when client starts a request.

Event:'http.client.request.error'#

Emitted when an error occurs during a client request.

Event:'http.client.response.finish'#

Emitted when client receives a response.

Event:'http.server.request.start'#

Emitted when server receives a request.

Event:'http.server.response.created'#

Emitted when server creates a response.The event is emitted before the response is sent.

Event:'http.server.response.finish'#

Emitted when server sends a response.

HTTP/2#

Stability: 1 - Experimental

Event:'http2.client.stream.created'#

Emitted when a stream is created on the client.

Event:'http2.client.stream.start'#

Emitted when a stream is started on the client.

Event:'http2.client.stream.error'#

Emitted when an error occurs during the processing of a stream on the client.

Event:'http2.client.stream.finish'#

Emitted when a stream is received on the client.

Event:'http2.client.stream.bodyChunkSent'#

Emitted when a chunk of the client stream body is being sent.

Event:'http2.client.stream.bodySent'#

Emitted after the client stream body has been fully sent.

Event:'http2.client.stream.close'#

Emitted when a stream is closed on the client. The HTTP/2 error code used whenclosing the stream can be retrieved using thestream.rstCode property.

Event:'http2.server.stream.created'#

Emitted when a stream is created on the server.

Event:'http2.server.stream.start'#

Emitted when a stream is started on the server.

Event:'http2.server.stream.error'#

Emitted when an error occurs during the processing of a stream on the server.

Event:'http2.server.stream.finish'#

Emitted when a stream is sent on the server.

Event:'http2.server.stream.close'#

Emitted when a stream is closed on the server. The HTTP/2 error code used whenclosing the stream can be retrieved using thestream.rstCode property.

Modules#

Stability: 1 - Experimental

Event:'module.require.start'#
  • event<Object> containing the following properties
    • id Argument passed torequire(). Module name.
    • parentFilename Name of the module that attempted to require(id).

Emitted whenrequire() is executed. Seestart event.

Event:'module.require.end'#
  • event<Object> containing the following properties
    • id Argument passed torequire(). Module name.
    • parentFilename Name of the module that attempted to require(id).

Emitted when arequire() call returns. Seeend event.

Event:'module.require.error'#
  • event<Object> containing the following properties
    • id Argument passed torequire(). Module name.
    • parentFilename Name of the module that attempted to require(id).
  • error<Error>

Emitted when arequire() throws an error. Seeerror event.

Event:'module.import.asyncStart'#
  • event<Object> containing the following properties
    • id Argument passed toimport(). Module name.
    • parentURL URL object of the module that attempted to import(id).

Emitted whenimport() is invoked. SeeasyncStart event.

Event:'module.import.asyncEnd'#
  • event<Object> containing the following properties
    • id Argument passed toimport(). Module name.
    • parentURL URL object of the module that attempted to import(id).

Emitted whenimport() has completed. SeeasyncEnd event.

Event:'module.import.error'#
  • event<Object> containing the following properties
    • id Argument passed toimport(). Module name.
    • parentURL URL object of the module that attempted to import(id).
  • error<Error>

Emitted when aimport() throws an error. Seeerror event.

NET#

Stability: 1 - Experimental

Event:'net.client.socket'#

Emitted when a new TCP or pipe client socket connection is created.

Event:'net.server.socket'#

Emitted when a new TCP or pipe connection is received.

Event:'tracing:net.server.listen:asyncStart'#

Emitted whennet.Server.listen() is invoked, before the port or pipe is actually setup.

Event:'tracing:net.server.listen:asyncEnd'#

Emitted whennet.Server.listen() has completed and thus the server is ready to accept connection.

Event:'tracing:net.server.listen:error'#

Emitted whennet.Server.listen() is returning an error.

UDP#

Stability: 1 - Experimental

Event:'udp.socket'#

Emitted when a new UDP socket is created.

Process#

Stability: 1 - Experimental

Added in: v16.18.0
Event:'child_process'#

Emitted when a new process is created.

Event:'execve'#

Emitted whenprocess.execve() is invoked.

Worker Thread#

Stability: 1 - Experimental

Added in: v16.18.0
Event:'worker_threads'#

Emitted when a new thread is created.