JSPM

diagnostics_channel

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 329206
  • Score
    100M100P100Q203623F
  • License MIT

Exposes a polyfill for the Node.js module diagnostics_channel

Package Exports

  • diagnostics_channel

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (diagnostics_channel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

diagnostics_channel-polyfill

Exposes a polyfill for the Node.js module diagnostics_channel.

As of now, the Node.js module diagnostics_channel is only available in Node ^14.17.0 || >=15.1.0. This aim to allow using the same API on older versions of Node.

Install

npm i diagnostics_channel

Usage

Refer to the official documentation: https://nodejs.org/api/diagnostics_channel.html

Notes

  • This module and the one included in Node core do NOT share the same channels, they live independently.
  • Since WeakReference is not available, channels will NOT be garbage collected when no reference is held in user-land. An additional function is provided to do manual cleanup if needed: dc.deleteChannel(). This should not be needed in a typical scenario. Only use this method if you know why you are doing it.
const dc = require('diagnostics_channel');

const a = dc.channel('test');
const b = dc.channel('test');

// channel is memoized
console.log(a === b); // true

dc.deleteChannel('test');

const c = dc.channel('test');

// memoized channel was deleted and a new instance was memoized
console.log(a === c); // false
  • Since ERR_INVALID_ARG_TYPE is not available, a simplfied copy of this error is included.
  • Since triggerUncaughtException() is not available, if an exception is thrown in a subscriber, the polyfill will instead simply re-throw the error inside a process.nextTick(), which has a similar behavior except when the process crashes because of that exception: the crash message will point to this polyfill instead of where the error was created (ie: in the subscriber).