Lỗi no process is associated with this object

The

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

7 event is emitted when Node.js empties its event loop and has no additional work to schedule. Normally, the Node.js process will exit when there is no work scheduled, but a listener registered on the

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

7 event can make asynchronous calls, and thereby cause the Node.js process to continue.

The listener callback function is invoked with the value of passed as the only argument.

The

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

7 event is not emitted for conditions causing explicit termination, such as calling or uncaught exceptions.

The

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

7 should not be used as an alternative to the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

04 event unless the intention is to schedule additional work.

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

05

Added in: v0.7.7

If the Node.js process is spawned with an IPC channel [see the Child Process and Cluster documentation], the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

05 event will be emitted when the IPC channel is closed.

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

04

Added in: v0.1.7

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 08

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

04 event is emitted when the Node.js process is about to exit as a result of either:

  • The import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 02 method being called explicitly;
  • The Node.js event loop no longer having any additional work to perform.

There is no way to prevent the exiting of the event loop at this point, and once all

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

04 listeners have finished running the Node.js process will terminate.

The listener callback function is invoked with the exit code specified either by the property, or the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

13 argument passed to the method.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

Listener functions must only perform synchronous operations. The Node.js process will exit immediately after calling the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

04 event listeners causing any additional work still queued in the event loop to be abandoned. In the following example, for instance, the timeout will never occur:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

16

Added in: v0.5.10

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 17 | | | | a parsed JSON object or a serializable primitive value.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 18 | a or object, or undefined.

If the Node.js process is spawned with an IPC channel [see the Child Process and Cluster documentation], the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

16 event is emitted whenever a message sent by a parent process using is received by the child process.

The message goes through serialization and parsing. The resulting message might not be the same as what is originally sent.

If the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

23 option was set to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

24 used when spawning the process, the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

17 argument can contain data that JSON is not able to represent. See for more details.

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

27

Added in: v10.12.0Deprecated since: v17.6.0, v16.15.0

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    28 The resolution type. One of

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    29 or

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 30.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 31 The promise that resolved or rejected more than once.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 32 The value with which the promise was either resolved or rejected after the original resolve.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

27 event is emitted whenever a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 has been either:

  • Resolved more than once.
  • Rejected more than once.
  • Rejected after resolve.
  • Resolved after reject.

This is useful for tracking potential errors in an application while using the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 constructor, as multiple resolutions are silently swallowed. However, the occurrence of this event does not necessarily indicate an error. For example,

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

36 can trigger a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

27 event.

Because of the unreliability of the event in cases like the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

36 example above it has been deprecated.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

39

Added in: v1.4.1

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 31 The late handled promise.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

39 event is emitted whenever a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 has been rejected and an error handler was attached to it [using

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

43, for example] later than one turn of the Node.js event loop.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 object would have previously been emitted in an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event, but during the course of processing gained a rejection handler.

There is no notion of a top level for a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 chain at which rejections can always be handled. Being inherently asynchronous in nature, a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 rejection can be handled at a future point in time, possibly much later than the event loop turn it takes for the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event to be emitted.

Another way of stating this is that, unlike in synchronous code where there is an ever-growing list of unhandled exceptions, with Promises there can be a growing-and-shrinking list of unhandled rejections.

In synchronous code, the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 event is emitted when the list of unhandled exceptions grows.

In asynchronous code, the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event is emitted when the list of unhandled rejections grows, and the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

39 event is emitted when the list of unhandled rejections shrinks.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

In this example, the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

52

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

53 will grow and shrink over time, reflecting rejections that start unhandled and then become handled. It is possible to record such errors in an error log, either periodically [which is likely best for long-running application] or upon process exit [which is likely most convenient for scripts].

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 55 The uncaught exception.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    56 Indicates if the exception originates from an unhandled rejection or from a synchronous error. Can either be

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    49 or

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    45. The latter is used when an exception happens in a

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    34 based async context [or if a

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    34 is rejected] and flag set to

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    62 or

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 63 [which is the default] and the rejection is not handled, or when a rejection happens during the command line entry point's ES module static loading phase.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 event is emitted when an uncaught JavaScript exception bubbles all the way back to the event loop. By default, Node.js handles such exceptions by printing the stack trace to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

65 and exiting with code 1, overriding any previously set . Adding a handler for the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 event overrides this default behavior. Alternatively, change the in the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 handler which will result in the process exiting with the provided exit code. Otherwise, in the presence of such handler the process will exit with 0.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

It is possible to monitor

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 events without overriding the default behavior to exit the process by installing a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

71 listener.

Warning: Using

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 correctly

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 is a crude mechanism for exception handling intended to be used only as a last resort. The event should not be used as an equivalent to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

74. Unhandled exceptions inherently mean that an application is in an undefined state. Attempting to resume application code without properly recovering from the exception can cause additional unforeseen and unpredictable issues.

Exceptions thrown from within the event handler will not be caught. Instead the process will exit with a non-zero exit code and the stack trace will be printed. This is to avoid infinite recursion.

Attempting to resume normally after an uncaught exception can be similar to pulling out the power cord when upgrading a computer. Nine out of ten times, nothing happens. But the tenth time, the system becomes corrupted.

The correct use of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 is to perform synchronous cleanup of allocated resources [e.g. file descriptors, handles, etc] before shutting down the process. It is not safe to resume normal operation after

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49.

To restart a crashed application in a more reliable way, whether

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 is emitted or not, an external monitor should be employed in a separate process to detect application failures and recover or restart as needed.

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

71

Added in: v13.7.0, v12.17.0

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 55 The uncaught exception.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    56 Indicates if the exception originates from an unhandled rejection or from synchronous errors. Can either be

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    49 or

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    45. The latter is used when an exception happens in a

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    34 based async context [or if a

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    34 is rejected] and flag set to

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    62 or

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 63 [which is the default] and the rejection is not handled, or when a rejection happens during the command line entry point's ES module static loading phase.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

71 event is emitted before an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 event is emitted or a hook installed via is called.

Installing an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

71 listener does not change the behavior once an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 event is emitted. The process will still crash if no

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

49 listener is installed.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

Event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 95 | The object with which the promise was rejected [typically an object].
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 31 The rejected promise.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event is emitted whenever a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 is rejected and no error handler is attached to the promise within a turn of the event loop. When programming with Promises, exceptions are encapsulated as "rejected promises". Rejections can be caught and handled using

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

43 and are propagated through a

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

34 chain. The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event is useful for detecting and keeping track of promises that were rejected whose rejections have not yet been handled.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

The following will also trigger the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event to be emitted:

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

In this example case, it is possible to track the rejection as a developer error as would typically be the case for other

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 events. To address such failures, a non-operational

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

05 handler may be attached to

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

06, which would prevent the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

45 event from being emitted.

Event:

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

08

Added in: v6.0.0

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    09 Key properties of the warning are:

    • import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];

      10 The name of the warning. Default:

      import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
    • import process from 'node:process'; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      const process = require['node:process']; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      17 A system-provided description of the warning.
    • import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      13 A stack trace to the location in the code where the warning was issued.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

08 event is emitted whenever Node.js emits a process warning.

A process warning is similar to an error in that it describes exceptional conditions that are being brought to the user's attention. However, warnings are not part of the normal Node.js and JavaScript error handling flow. Node.js can emit warnings whenever it detects bad coding practices that could lead to sub-optimal application performance, bugs, or security vulnerabilities.

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

0

By default, Node.js will print process warnings to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

65. The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

16 command-line option can be used to suppress the default console output but the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

08 event will still be emitted by the

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

4 object. Currently, it is not possible to suppress specific warning types other than deprecation warnings. To suppress deprecation warnings, check out the flag.

The following example illustrates the warning that is printed to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

65 when too many listeners have been added to an event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

1

In contrast, the following example turns off the default warning output and adds a custom handler to the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

08 event:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

2

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

22 command-line option can be used to have the default console output for warnings include the full stack trace of the warning.

Launching Node.js using the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

23 command-line flag will cause custom deprecation warnings to be thrown as exceptions.

Using the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

24 command-line flag will cause the custom deprecation to be printed to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

65 along with the stack trace.

Using the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

19 command-line flag will suppress all reporting of the custom deprecation.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

27 command-line flags only affect warnings that use the name

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

28.

Event:

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

29

Added in: v16.2.0, v14.18.0

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 30 The that was created.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

29 event is emitted after a new thread has been created.

Emitting custom warnings

See the method for issuing custom or application-specific warnings.

Node.js warning names

There are no strict guidelines for warning types [as identified by the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

10 property] emitted by Node.js. New types of warnings can be added at any time. A few of the warning types that are most common include:

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    28 - Indicates use of a deprecated Node.js API or feature. Such warnings must include a

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 35 property identifying the deprecation code.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 36 - Indicates use of an experimental Node.js API or feature. Such features must be used with caution as they may change at any time and are not subject to the same strict semantic-versioning and long-term support policies as supported features.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    37 - Indicates that too many listeners for a given event have been registered on either an

    import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

    6 or

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 39. This is often an indication of a memory leak.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    40 - Indicates that a numeric value that cannot fit within a 32-bit signed integer has been provided to either the

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    41 or

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 42 functions.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 43 - Indicates use of an unsupported option or feature that will be ignored rather than treated as an error. One example is use of the HTTP response status message when using the HTTP/2 compatibility API.

Signal events

Signal events will be emitted when the Node.js process receives a signal. Please refer to

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

44 for a listing of standard POSIX signal names such as

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

45,

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

46, etc.

Signals are not available on threads.

The signal handler will receive the signal's name [

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

45,

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

49, etc.] as the first argument.

The name of each event will be the uppercase common name for the signal [e.g.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

45 for

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

51 signals].

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

3

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 52 is reserved by Node.js to start the debugger. It's possible to install a listener but doing so might interfere with the debugger.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    49 and

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    45 have default handlers on non-Windows platforms that reset the terminal mode before exiting with code

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 55. If one of these signals has a listener installed, its default behavior will be removed [Node.js will no longer exit].
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 56 is ignored by default. It can have a listener installed.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    46 is generated on Windows when the console window is closed, and on other platforms under various similar conditions. See

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    44. It can have a listener installed, however Node.js will be unconditionally terminated by Windows about 10 seconds later. On non-Windows platforms, the default behavior of

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 59 is to terminate Node.js, but once a listener has been installed its default behavior will be removed.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 49 is not supported on Windows, it can be listened on.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 45 from the terminal is supported on all platforms, and can usually be generated with Ctrl+C [though this may be configurable]. It is not generated when is enabled and Ctrl+C is used.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 62 is delivered on Windows when Ctrl+Break is pressed. On non-Windows platforms, it can be listened on, but there is no way to send or generate it.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 63 is delivered when the console has been resized. On Windows, this will only happen on write to the console when the cursor is being moved, or when a readable tty is used in raw mode.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 64 cannot have a listener installed, it will unconditionally terminate Node.js on all platforms.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 65 cannot have a listener installed.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    66,

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    67,

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    68, and

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    69, when not raised artificially using

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 70, inherently leave the process in a state from which it is not safe to call JS listeners. Doing so might cause the process to stop responding.
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 71 can be sent to test for the existence of a process, it has no effect if the process exists, but will throw an error if the process does not exist.

Windows does not support signals so has no equivalent to termination by signal, but Node.js offers some emulation with , and :

  • Sending import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    51,

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    75, and

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 76 will cause the unconditional termination of the target process, and afterwards, subprocess will report that the process was terminated by signal.
  • Sending signal import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 71 can be used as a platform independent way to test for the existence of a process.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

78

Added in: v0.7.0

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

78 method causes the Node.js process to exit immediately and generate a core file.

This feature is not available in threads.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81

Added in: v10.10.0

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81 property is a special, read-only

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

83 of flags allowable within the environment variable.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81 extends

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

83, but overrides

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

87 to recognize several different possible flag representations.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

88 will return

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

89 in the following cases:

  • Flags may omit leading single [ import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];
  • or double [ import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];
  • dashes; e.g., import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    92 for

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    93, or

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    94 for

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 95.
  • Flags passed through to V8 [as listed in import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];
  • may replace one or more non-leading dashes for an underscore, or vice-versa; e.g., import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    97,

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    98,

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 99, etc.
  • Flags may contain one or more equals [ import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
  • characters; all characters after and including the first equals will be ignored; e.g., import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    01.
  • Flags must be allowable within .

When iterating over

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81, flags will appear only once; each will begin with one or more dashes. Flags passed through to V8 will contain underscores instead of non-leading dashes:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

4

The methods

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

04,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

05, and

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

06 of

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81 do nothing, and will fail silently.

If Node.js was compiled without support [shown in ],

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

81 will contain what would have been allowable.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

11

Added in: v0.5.0

The operating system CPU architecture for which the Node.js binary was compiled. Possible values are:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

12,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

13,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

14,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

15,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

16,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

17,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

18,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

19,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

20,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

21,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

22, and

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

23.

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

5

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

24

Added in: v0.1.27

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

24 property returns an array containing the command-line arguments passed when the Node.js process was launched. The first element will be . See

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

27 if access to the original value of

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

28 is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command-line arguments.

For example, assuming the following script for

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

29:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

6

Launching the Node.js process as:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

7

Would generate the output:

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

8

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

27

Added in: v6.4.0

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

27 property stores a read-only copy of the original value of

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

28 passed when Node.js starts.

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

9

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

33

If the Node.js process was spawned with an IPC channel [see the Child Process documentation], the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

33 property is a reference to the IPC channel. If no IPC channel exists, this property is

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

35.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

36

Added in: v7.1.0

This method makes the IPC channel keep the event loop of the process running if

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

37 has been called before.

Typically, this is managed through the number of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

05 and

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

16 listeners on the

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

4 object. However, this method can be used to explicitly request a specific behavior.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

41

Added in: v7.1.0

This method makes the IPC channel not keep the event loop of the process running, and lets it finish even while the channel is open.

Typically, this is managed through the number of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

05 and

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

16 listeners on the

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

4 object. However, this method can be used to explicitly request a specific behavior.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

45

Added in: v0.1.17

  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    46

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

47 method changes the current working directory of the Node.js process or throws an exception if doing so fails [for instance, if the specified

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

46 does not exist].

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

0

This feature is not available in threads.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

09

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

09 property returns a frozen

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

52 containing the JavaScript representation of the configure options used to compile the current Node.js executable. This is the same as the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

53 file that was produced when running the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

54 script.

An example of the possible output looks like:

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

1

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

55

Added in: v0.7.2

If the Node.js process is spawned with an IPC channel [see the Child Process and Cluster documentation], the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

55 property will return

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

89 so long as the IPC channel is connected and will return

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

58 after

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

59 is called.

Once

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

55 is

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

58, it is no longer possible to send messages over the IPC channel using

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

62.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

63

Added in: v19.6.0, v18.15.0

  • |

Gets the amount of memory available to the process [in bytes] based on limits imposed by the OS. If there is no such constraint, or the constraint is unknown,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

35 is returned.

See for more information.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

66

Added in: v6.1.0

  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];

    67 A previous return value from calling

    import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    68
  • Returns:
    • import process from 'node:process'; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      69
    • import process from 'node:process'; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      70

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

68 method returns the user and system CPU time usage of the current process, in an object with properties

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

69 and

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

70, whose values are microsecond values [millionth of a second]. These values measure time spent in user and system code respectively, and may end up being greater than actual elapsed time if multiple CPU cores are performing work for this process.

The result of a previous call to

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

68 can be passed as the argument to the function, to get a diff reading.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

2

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

75

Added in: v0.1.8

  • Returns:

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

75 method returns the current working directory of the Node.js process.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

3

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

77

Added in: v0.7.2

The port used by the Node.js debugger when enabled.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

4

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

59

Added in: v0.7.2

If the Node.js process is spawned with an IPC channel [see the Child Process and Cluster documentation], the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

59 method will close the IPC channel to the parent process, allowing the child process to exit gracefully once there are no other connections keeping it alive.

The effect of calling

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

59 is the same as calling from the parent process.

If the Node.js process was not spawned with an IPC channel,

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

59 will be

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

35.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

84

  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    85
  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    86
  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];

    87 Default:

    import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    88

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

89 method allows dynamically loading shared objects. It is primarily used by

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

90 to load C++ Addons, and should not be used directly, except in special cases. In other words, should be preferred over

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

89 unless there are specific reasons such as custom dlopen flags or loading from ES modules.

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

87 argument is an integer that allows to specify dlopen behavior. See the documentation for details.

An important requirement when calling

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

89 is that the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

85 instance must be passed. Functions exported by the C++ Addon are then accessible via

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

97.

The example below shows how to load a C++ Addon, named

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

98, that exports a

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

99 function. All the symbols are loaded before the call returns, by passing the

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

00 constant. In this example the constant is assumed to be available.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

5

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

01

Added in: v8.0.0

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 09 | The warning to emit.
  • import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    03

    • import process from 'node:process'; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      const process = require['node:process']; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

      28 When

      import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];

      09 is a

      import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

      06,

      import process from 'node:process'; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      const process = require['node:process']; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

      28 is the name to use for the type of warning being emitted. Default:

      import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
    • import process from 'node:process'; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      const process = require['node:process']; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      08 A unique identifier for the warning instance being emitted.
    • import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

      10 When

      import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];

      09 is a

      import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

      06,

      import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

      10 is an optional function used to limit the generated stack trace. Default:

      import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    • import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => {
       console.error[type, promise, reason];  
       setImmediate[[] => process.exit[1]];  
      
      }]; async function main[] {
       try {  
         return await new Promise[[resolve, reject] => {  
           resolve['First call'];  
           resolve['Swallowed resolve'];  
           reject[new Error['Swallowed reject']];  
         }];  
       } catch {  
         throw new Error['Failed'];  
       }  
      
      } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
      15 Additional text to include with the error.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

32 method can be used to emit custom or application specific process warnings. These can be listened for by adding a handler to the event.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

6

In this example, an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 object is generated internally by

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

32 and passed through to the handler.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

7

If

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

09 is passed as an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 object, the

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

03 argument is ignored.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

24

Added in: v6.0.0

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 09 | The warning to emit.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    28 When

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    09 is a

    import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    06,

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    28 is the name to use for the type of warning being emitted. Default:

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 11.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 08 A unique identifier for the warning instance being emitted.
  • import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    10 When

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    09 is a

    import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    06,

    import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    10 is an optional function used to limit the generated stack trace. Default:

    import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    14.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

32 method can be used to emit custom or application specific process warnings. These can be listened for by adding a handler to the event.

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

8

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

9

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

0

In each of the previous examples, an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 object is generated internally by

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

32 and passed through to the handler.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

1

If

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

09 is passed as an

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 object, it will be passed through to the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

08 event handler unmodified [and the optional

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

28,

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

08 and

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

10 arguments will be ignored]:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

2

A

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

48 is thrown if

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

09 is anything other than a string or

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 object.

While process warnings use

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

96 objects, the process warning mechanism is not a replacement for normal error handling mechanisms.

The following additional handling is implemented if the warning

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

28 is

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

28:

  • If the import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 23 command-line flag is used, the deprecation warning is thrown as an exception rather than being emitted as an event.
  • If the import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 19 command-line flag is used, the deprecation warning is suppressed.
  • If the import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    24 command-line flag is used, the deprecation warning is printed to

    import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 65 along with the full stack trace.

Avoiding duplicate warnings

As a best practice, warnings should be emitted only once per process. To do so, place the

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

58 behind a boolean.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

3

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59

The

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59 property returns an object containing the user environment. See

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

61.

An example of this object looks like:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

4

It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or [unless explicitly requested] to other threads. In other words, the following example would not work:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

5

While the following will:

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

6

Assigning a property on

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59 will implicitly convert the value to a string. This behavior is deprecated. Future versions of Node.js may throw an error when the value is not a string, number, or boolean.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

7

Use

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

64 to delete a property from

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

8

On Windows operating systems, environment variables are case-insensitive.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

9

Unless explicitly specified when creating a instance, each thread has its own copy of

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59, based on its parent thread's

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59, or whatever was specified as the

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

70 option to the constructor. Changes to

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59 will not be visible across threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

59 on a instance operates in a case-sensitive manner unlike the main thread.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

76

Added in: v0.7.7

The

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

76 property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

0

Results in

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

76:

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

1

And

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

24:

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

2

Refer to for the detailed behavior of worker threads with this property.

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

26

Added in: v0.1.100

The

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

26 property returns the absolute pathname of the executable that started the Node.js process. Symbolic links, if any, are resolved.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

3

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

84

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

    08 | | | The exit code. For string type, only integer strings [e.g.,'1'] are allowed. Default:

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 71.

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 method instructs Node.js to terminate the process synchronously with an exit status of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

08. If

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

08 is omitted, exit uses either the 'success' code

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71 or the value of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

00 if it has been set. Node.js will not terminate until all the event listeners are called.

To exit with a 'failure' code:

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

4

The shell that executed Node.js should see the exit code as

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

93.

Calling

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 will force the process to exit as quickly as possible even if there are still asynchronous operations pending that have not yet completed fully, including I/O operations to

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95 and

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96.

In most situations, it is not actually necessary to call

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 explicitly. The Node.js process will exit on its own if there is no additional work pending in the event loop. The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

00 property can be set to tell the process which exit code to use when the process exits gracefully.

For instance, the following example illustrates a misuse of the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 method that could lead to data printed to stdout being truncated and lost:

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

5

The reason this is problematic is because writes to

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95 in Node.js are sometimes asynchronous and may occur over multiple ticks of the Node.js event loop. Calling

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02, however, forces the process to exit before those additional writes to

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

02 can be performed.

Rather than calling

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 directly, the code should set the

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

00 and allow the process to exit naturally by avoiding scheduling any additional work for the event loop:

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

6

If it is necessary to terminate the Node.js process due to an error condition, throwing an uncaught error and allowing the process to terminate accordingly is safer than calling

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02.

In threads, this function stops the current thread rather than the current process.

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

00

  • | | | The exit code. For string type, only integer strings [e.g.,'1'] are allowed. Default: import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    35.

A number which will be the process exit code, when the process either exits gracefully, or is exited via without specifying a code.

Specifying a code to will override any previous setting of

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

00.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

12

Added in: v17.3.0, v16.14.0

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

12 method returns an array of strings containing the types of the active resources that are currently keeping the event loop alive.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

7

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

14

Added in: v2.0.0

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

14 method returns the numerical effective group identity of the Node.js process. [See

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

16.]

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

8

This function is only available on POSIX platforms [i.e. not Windows or Android].

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

17

Added in: v2.0.0

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

17 method returns the numerical effective user identity of the process. [See

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

19.]

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

9

This function is only available on POSIX platforms [i.e. not Windows or Android].

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

20

Added in: v0.1.31

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

20 method returns the numerical group identity of the process. [See

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

22.]

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

0

This function is only available on POSIX platforms [i.e. not Windows or Android].

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

23

Added in: v0.9.4

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

23 method returns an array with the supplementary group IDs. POSIX leaves it unspecified if the effective group ID is included but Node.js ensures it always is.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

1

This function is only available on POSIX platforms [i.e. not Windows or Android].

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

25

Added in: v0.1.28

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

25 method returns the numeric user identity of the process. [See

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

27.]

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

2

This function is only available on POSIX platforms [i.e. not Windows or Android].

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

28

Added in: v9.3.0

  • Returns:

Indicates whether a callback has been set using .

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

30

Added in: v0.7.6

  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    31 The result of a previous call to

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 32
  • Returns:

This is the legacy version of before

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

34 was introduced in JavaScript.

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

32 method returns the current high-resolution real time in a

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

36 tuple

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

37, where

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

38 is the remaining part of the real time that can't be represented in second precision.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

31 is an optional parameter that must be the result of a previous

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

32 call to diff with the current time. If the parameter passed in is not a tuple

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

37, a

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

48 will be thrown. Passing in a user-defined array instead of the result of a previous call to

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

32 will lead to undefined behavior.

These times are relative to an arbitrary time in the past, and not related to the time of day and therefore not subject to clock drift. The primary use is for measuring performance between intervals:

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

3

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

33

Added in: v10.7.0

  • Returns:

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

34 version of the method returning the current high-resolution real time in nanoseconds as a

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

34.

Unlike , it does not support an additional

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

31 argument since the difference can just be computed directly by subtraction of the two

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

34s.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

4

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

51

Added in: v0.9.4

  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    69 | The user name or numeric identifier.
  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 53 | A group name or numeric identifier.

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

54 method reads the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

55 file and initializes the group access list, using all groups of which the user is a member. This is a privileged operation that requires that the Node.js process either have

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

56 access or the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

57 capability.

Use care when dropping privileges:

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

5

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

59

Added in: v0.0.6

  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 60 A process ID
  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    61 | The signal to send, either as a string or number. Default:

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 49.

The

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

72 method sends the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

61 to the process identified by

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

60.

Signal names are strings such as

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

45 or

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

46. See and

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

70 for more information.

This method will throw an error if the target

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

60 does not exist. As a special case, a signal of

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71 can be used to test for the existence of a process. Windows platforms will throw an error if the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

60 is used to kill a process group.

Even though the name of this function is

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

72, it is really just a signal sender, like the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

73 system call. The signal sent may do something other than kill the target process.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

6

When

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

74 is received by a Node.js process, Node.js will start the debugger. See .

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

75

Added in: v0.1.17Deprecated since: v14.0.0

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

75 property provides an alternative way of retrieving . The difference is that if the main module changes at runtime, may still refer to the original main module in modules that were required before the change occurred. Generally, it's safe to assume that the two refer to the same module.

As with ,

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

75 will be

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

35 if there is no entry script.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

82

  • Returns:
    • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      83
    • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      84
    • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      85
    • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      86
    • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => {
       unhandledRejections.set[promise, reason];  
      
      }]; process.on['rejectionHandled', [promise] => {
       unhandledRejections.delete[promise];  
      
      }];
      87

Returns an object describing the memory usage of the Node.js process measured in bytes.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

7

  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    84 and

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 85 refer to V8's memory usage.
  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 86 refers to the memory usage of C++ objects bound to JavaScript objects managed by V8.
  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 83, Resident Set Size, is the amount of space occupied in the main memory device [that is a subset of the total allocated memory] for the process, including all C++ and JavaScript objects and code.
  • import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    87 refers to memory allocated for

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    93s and

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    94s, including all Node.js

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    95s. This is also included in the

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

    86 value. When Node.js is used as an embedded library, this value may be

    import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    71 because allocations for

    import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; 93s may not be tracked in that case.

When using threads,

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

83 will be a value that is valid for the entire process, while the other fields will only refer to the current thread.

The

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

82 method iterates over each page to gather information about memory usage which might be slow depending on the program memory allocations.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

02

Added in: v15.6.0, v14.18.0

  • Returns:

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

02 method returns an integer representing the Resident Set Size [RSS] in bytes.

The Resident Set Size, is the amount of space occupied in the main memory device [that is a subset of the total allocated memory] for the process, including all C++ and JavaScript objects and code.

This is the same value as the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

83 property provided by

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

82 but

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

02 is faster.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

8

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

07

  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    08
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

    09 Additional arguments to pass when invoking the

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    08

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11 adds

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

08 to the "next tick queue". This queue is fully drained after the current operation on the JavaScript stack runs to completion and before the event loop is allowed to continue. It's possible to create an infinite loop if one were to recursively call

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11. See the guide for more background.

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

9

This is important when developing APIs in order to give users the opportunity to assign event handlers after an object has been constructed but before any I/O has occurred:

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

0

It is very important for APIs to be either 100% synchronous or 100% asynchronous. Consider this example:

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

1

This API is hazardous because in the following case:

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

2

It is not clear whether

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

14 or

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

15 will be called first.

The following approach is much better:

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

3

When to use

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

16 vs.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11

The API is an alternative to

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11 that also defers execution of a function using the same microtask queue used to execute the then, catch, and finally handlers of resolved promises. Within Node.js, every time the "next tick queue" is drained, the microtask queue is drained immediately after.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

4

For most userland use cases, the

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

16 API provides a portable and reliable mechanism for deferring execution that works across multiple JavaScript platform environments and should be favored over

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11. In simple scenarios,

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

16 can be a drop-in replacement for

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

5

One note-worthy difference between the two APIs is that

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11 allows specifying additional values that will be passed as arguments to the deferred function when it is called. Achieving the same result with

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

16 requires using either a closure or a bound function:

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

6

There are minor differences in the way errors raised from within the next tick queue and microtask queue are handled. Errors thrown within a queued microtask callback should be handled within the queued callback when possible. If they are not, the

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

26 event handler can be used to capture and handle the errors.

When in doubt, unless the specific capabilities of

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

11 are needed, use

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

16.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

29

Added in: v0.8.0

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

29 property indicates whether the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

19 flag is set on the current Node.js process. See the documentation for the and the for more information about this flag's behavior.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

34

Added in: v20.0.0

This API is available through the flag.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

34 is an object whose methods are used to manage permissions for the current process. Additional documentation is available in the .

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

37

Added in: v20.0.0

  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    38
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    39
  • Returns:

Verifies that the process is able to access the given scope and reference. If no reference is provided, a global scope is assumed, for instance,

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

40 will check if the process has ALL file system read permissions.

The reference has a meaning based on the provided scope. For example, the reference when the scope is File System means files and folders.

The available scopes are:

  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    41 - All File System
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    42 - File System read operations
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    43 - File System write operations
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    44 - Child process spawning operations
  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; 30 - Worker thread spawning operation

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

7

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

46

Added in: v0.1.15

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

46 property returns the PID of the process.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

8

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

48

Added in: v0.1.16

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

48 property returns a string identifying the operating system platform for which the Node.js binary was compiled.

Currently possible values are:

  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    50
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    51
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    52
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    53
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    54
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    55
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    56

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

9

The value

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

57 may also be returned if the Node.js is built on the Android operating system. However, Android support in Node.js .

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

58

Added in: v9.2.0, v8.10.0, v6.13.0

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

58 property returns the PID of the parent of the current process.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

0

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

60

The

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

60 property returns an

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

52 containing metadata related to the current release, including URLs for the source tarball and headers-only tarball.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

60 contains the following properties:

  • import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

    10 A value that will always be

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    65.
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

    66 an absolute URL pointing to a

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    67 file containing the source code of the current release.
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

    68 an absolute URL pointing to a

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    67 file containing only the source header files for the current release. This file is significantly smaller than the full source file and can be used for compiling Node.js native add-ons.
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

    70 | an absolute URL pointing to a

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    71 file matching the architecture and version of the current release. This file is used for compiling Node.js native add-ons. This property is only present on Windows builds of Node.js and will be missing on all other platforms.
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

    72 | a string label identifying the LTS label for this release. This property only exists for LTS releases and is

    import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];

    35 for all other release types, including Current releases. Valid values include the LTS Release code names [including those that are no longer supported].

    • import process from 'node:process'; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      const process = require['node:process']; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      74 for the 14.x LTS line beginning with 14.15.0.
    • import process from 'node:process'; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      const process = require['node:process']; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      75 for the 16.x LTS line beginning with 16.13.0.
    • import process from 'node:process'; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      const process = require['node:process']; process.on['uncaughtException', [err, origin] => {
       fs.writeSync[  
         process.stderr.fd,  
         Caught exception: ${err}\n +  
         Exception origin: ${origin},  
       ];  
      
      }]; setTimeout[[] => {
       console.log['This will still run.'];  
      
      }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
      76 for the 18.x LTS line beginning with 18.12.0. For other LTS Release code names, see Node.js Changelog Archive

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

1

In custom builds from non-release versions of the source tree, only the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

10 property may be present. The additional properties should not be relied upon to exist.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

78

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

78 is an object whose methods are used to generate diagnostic reports for the current process. Additional documentation is available in the report documentation.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

80

Added in: v13.12.0, v12.17.0

Write reports in a compact format, single-line JSON, more easily consumable by log processing systems than the default multi-line format designed for human consumption.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

2

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

81

Directory where the report is written. The default value is the empty string, indicating that reports are written to the current working directory of the Node.js process.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

3

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

82

Filename where the report is written. If set to the empty string, the output filename will be comprised of a timestamp, PID, and sequence number. The default value is the empty string.

If the value of

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

82 is set to

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

84 or

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

85, the report is written to the stdout or stderr of the process respectively.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

4

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

86

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 55 A custom error used for reporting the JavaScript stack.
  • Returns:

Returns a JavaScript Object representation of a diagnostic report for the running process. The report's JavaScript stack trace is taken from

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

55, if present.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

5

Additional documentation is available in the report documentation.

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

89

If

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

89, a diagnostic report is generated on fatal errors, such as out of memory errors or failed C++ assertions.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

6

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

91

If

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

89, a diagnostic report is generated when the process receives the signal specified by

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

93.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

7

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

94

If

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

89, a diagnostic report is generated on uncaught exception.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

8

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

93

The signal used to trigger the creation of a diagnostic report. Defaults to

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

97.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

9

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

98

  • import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];
    const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
    console.log['This will not run'];  
    
    }, 0]; }];

    86 Name of the file where the report is written. This should be a relative path, that will be appended to the directory specified in

    import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    81, or the current working directory of the Node.js process, if unspecified.
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 55 A custom error used for reporting the JavaScript stack.
  • Returns: Returns the filename of the generated report.

Writes a diagnostic report to a file. If

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

86 is not provided, the default filename includes the date, time, PID, and a sequence number. The report's JavaScript stack trace is taken from

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

55, if present.

If the value of

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

86 is set to

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

84 or

import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[

process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.']; const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
process.stderr.fd,
`Caught exception: ${err}\n` +
`Exception origin: ${origin}`,
]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];

85, the report is written to the stdout or stderr of the process respectively.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

0

Additional documentation is available in the report documentation.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

07

Added in: v12.6.0

  • Returns: the resource usage for the current process. All of these values come from the import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

    08 call which returns a .

    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      10 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      11 computed in microseconds. It is the same value as .
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      13 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      14 computed in microseconds. It is the same value as .
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      16 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      17 which is the maximum resident set size used in kilobytes.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      18 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      19 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      20 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      21 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      22 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      23 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      24 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      25 which is the number of minor page faults for the process, see .
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      26 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      27 which is the number of major page faults for the process, see . This field is not supported on Windows.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      28 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      29 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      30 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      31 which is the number of times the file system had to perform input.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      32 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      33 which is the number of times the file system had to perform output.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      34 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      35 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      36 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      37 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      38 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      39 but is not supported by any platform.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      40 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      41 which is the number of times a CPU context switch resulted due to a process voluntarily giving up the processor before its time slice was completed [usually to await availability of a resource]. This field is not supported on Windows.
    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      42 maps to

      import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      43 which is the number of times a CPU context switch resulted due to a higher priority process becoming runnable or because the current process exceeded its time slice. This field is not supported on Windows.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

1

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

44

Added in: v0.5.9

  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 17
  • import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 18 |
  • import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    03 used to parameterize the sending of certain types of handles.

    import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
    const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
    return await new Promise[[resolve, reject] => {  
      resolve['First call'];  
      resolve['Swallowed resolve'];  
      reject[new Error['Swallowed reject']];  
    }];  
    
    } catch {
    throw new Error['Failed'];  
    
    } } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

    03 supports the following properties:

    • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js
      const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => {
       MyMonitoringTool.logSync[err, origin];  
      
      }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

      49 A value that can be used when passing instances of

      import process from 'node:process'; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0
      const process = require['node:process']; process.on['beforeExit', [code] => {
       console.log['Process beforeExit event with code: ', code];  
      
      }]; process.on['exit', [code] => {
       console.log['Process exit event with code: ', code];  
      
      }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

      20. When

      import process from 'node:process'; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       console.log[About to exit with code: ${code}];  
      
      }];

      89, the socket is kept open in the sending process. Default:

      import process from 'node:process'; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      const process = require['node:process']; process.on['exit', [code] => {
       setTimeout[[] => {  
         console.log['This will not run'];  
       }, 0];  
      
      }];
      58.
  • import process from 'node:process'; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    const process = require['node:process']; process.on['uncaughtException', [err, origin] => { fs.writeSync[
    process.stderr.fd,  
    Caught exception: ${err}\n +  
    Exception origin: ${origin},  
    
    ]; }]; setTimeout[[] => { console.log['This will still run.']; }, 500]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; console.log['This will not run.'];
    08
  • Returns:

If Node.js is spawned with an IPC channel, the

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

62 method can be used to send messages to the parent process. Messages will be received as a event on the parent's object.

If Node.js was not spawned with an IPC channel,

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

57 will be

import process from 'node:process'; process.on['exit', [code] => { setTimeout[[] => {

console.log['This will not run'];
}, 0]; }]; const process = require['node:process']; process.on['exit', [code] => { setTimeout[[] => {
console.log['This will not run'];
}, 0]; }];

35.

The message goes through serialization and parsing. The resulting message might not be the same as what is originally sent.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

59

Added in: v2.0.0

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 60 | A group name or ID

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

61 method sets the effective group identity of the process. [See

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

62.] The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

60 can be passed as either a numeric ID or a group name string. If a group name is specified, this method blocks while resolving the associated a numeric ID.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

2

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

65

Added in: v2.0.0

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 60 | A user name or ID

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

67 method sets the effective user identity of the process. [See

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

68.] The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

60 can be passed as either a numeric ID or a username string. If a username is specified, the method blocks while resolving the associated numeric ID.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

3

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

71

Added in: v0.1.31

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 60 | The group name or ID

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

73 method sets the group identity of the process. [See

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

74.] The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

60 can be passed as either a numeric ID or a group name string. If a group name is specified, this method blocks while resolving the associated numeric ID.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

4

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

77

Added in: v0.9.4

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 78

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

79 method sets the supplementary group IDs for the Node.js process. This is a privileged operation that requires the Node.js process to have

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

56 or the

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

57 capability.

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

78 array can contain numeric group IDs, group names, or both.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

5

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

84

Added in: v0.1.28

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 60 |

The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

84 method sets the user identity of the process. [See

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

87.] The

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

60 can be passed as either a numeric ID or a username string. If a username is specified, the method blocks while resolving the associated numeric ID.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

6

This function is only available on POSIX platforms [i.e. not Windows or Android]. This feature is not available in threads.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

90

Added in: v16.6.0, v14.18.0

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 91

This function enables or disables the Source Map v3 support for stack traces.

It provides same features as launching Node.js process with commandline options

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

92.

Only source maps in JavaScript files that are loaded after source maps has been enabled will be parsed and loaded.

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

93

Added in: v9.3.0

  • import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js 94 |

The

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

90 function sets a function that will be invoked when an uncaught exception occurs, which will receive the exception value itself as its first argument.

If such a function is set, the event will not be emitted. If

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

97 was passed from the command line or set through , the process will not abort. Actions configured to take place on exceptions such as report generations will be affected too

To unset the capture function,

import process from 'node:process'; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js const process = require['node:process']; process.on['uncaughtExceptionMonitor', [err, origin] => { MyMonitoringTool.logSync[err, origin]; }]; // Intentionally cause an exception, but don't catch it. nonexistentFunc[]; // Still crashes Node.js

99 may be used. Calling this method with a non-

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

00 argument while another capture function is set will throw an error.

Using this function is mutually exclusive with using the deprecated

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

01 built-in module.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

02

Added in: v20.7.0

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

02 property returns whether the Source Map v3 support for stack traces is enabled.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96

The

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96 property returns a stream connected to

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

65 [fd

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

07]. It is a [which is a stream] unless fd

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

07 refers to a file, in which case it is a stream.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96 differs from other Node.js streams in important ways. See for more information.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

11

This property refers to the value of underlying file descriptor of

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96. The value is fixed at

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

07. In threads, this field does not exist.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

15

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

15 property returns a stream connected to

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

17 [fd

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71]. It is a [which is a stream] unless fd

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71 refers to a file, in which case it is a stream.

For details of how to read from

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

17 see .

As a stream,

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

15 can also be used in "old" mode that is compatible with scripts written for Node.js prior to v0.10. For more information see .

In "old" streams mode the

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

17 stream is paused by default, so one must call

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

25 to read from it. Note also that calling

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

25 itself would switch stream to "old" mode.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

27

This property refers to the value of underlying file descriptor of

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

15. The value is fixed at

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71. In threads, this field does not exist.

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95

The

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95 property returns a stream connected to

import process from 'node:process'; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }]; const process = require['node:process']; const unhandledRejections = new Map[]; process.on['unhandledRejection', [reason, promise] => { unhandledRejections.set[promise, reason]; }]; process.on['rejectionHandled', [promise] => { unhandledRejections.delete[promise]; }];

02 [fd

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

93]. It is a [which is a stream] unless fd

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

93 refers to a file, in which case it is a stream.

For example, to copy

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

15 to

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95:

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

7

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95 differs from other Node.js streams in important ways. See for more information.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

40

This property refers to the value of underlying file descriptor of

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95. The value is fixed at

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

93. In threads, this field does not exist.

A note on process I/O

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

95 and

import process from 'node:process'; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {

return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call
const process = require['node:process']; process.on['multipleResolves', [type, promise, reason] => { console.error[type, promise, reason]; setImmediate[[] => process.exit[1]]; }]; async function main[] { try {
return await new Promise[[resolve, reject] => {
  resolve['First call'];
  resolve['Swallowed resolve'];
  reject[new Error['Swallowed reject']];
}];
} catch {
throw new Error['Failed'];
} } main[].then[console.log]; // resolve: Promise { 'First call' } 'Swallowed resolve' // reject: Promise { 'First call' } Error: Swallowed reject // at Promise [] // at new Promise [] // at main [] // First call

96 differ from other Node.js streams in important ways:

  1. They are used internally by and , respectively.
  2. Writes may be synchronous depending on what the stream is connected to and whether the system is Windows or POSIX:
    • Files: synchronous on Windows and POSIX
    • TTYs [Terminals]: asynchronous on Windows, synchronous on POSIX
    • Pipes [and sockets]: synchronous on Windows, asynchronous on POSIX

These behaviors are partly for historical reasons, as changing them would create backward incompatibility, but they are also expected by some users.

Synchronous writes avoid problems such as output written with

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

46 or

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

47 being unexpectedly interleaved, or not written at all if

import process from 'node:process'; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0 const process = require['node:process']; process.on['beforeExit', [code] => { console.log['Process beforeExit event with code: ', code]; }]; process.on['exit', [code] => { console.log['Process exit event with code: ', code]; }]; console.log['This message is displayed first.']; // Prints: // This message is displayed first. // Process beforeExit event with code: 0 // Process exit event with code: 0

02 is called before an asynchronous write completes. See for more information.

Warning: Synchronous writes block the event loop until the write has completed. This can be near instantaneous in the case of output to a file, but under high system load, pipes that are not being read at the receiving end, or with slow terminals or file systems, it's possible for the event loop to be blocked often enough and long enough to have severe negative performance impacts. This may not be a problem when writing to an interactive terminal session, but consider this particularly careful when doing production logging to the process output streams.

To check if a stream is connected to a context, check the

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

52 property.

For instance:

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

8

See the documentation for more information.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

53

Added in: v0.9.12

The initial value of

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

53 indicates whether the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

23 flag is set on the current Node.js process.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

53 is mutable, so whether or not deprecation warnings result in errors may be altered at runtime. See the documentation for the and the for more information.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

9

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59

Added in: v0.1.104

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59 property returns the current process title [i.e. returns the current value of

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

61]. Assigning a new value to

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59 modifies the current value of

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

61.

When a new value is assigned, different platforms will impose different maximum length restrictions on the title. Usually such restrictions are quite limited. For instance, on Linux and macOS,

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59 is limited to the size of the binary name plus the length of the command-line arguments because setting the

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59 overwrites the

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

66 memory of the process. Node.js v0.8 allowed for longer process title strings by also overwriting the

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

67 memory but that was potentially insecure and confusing in some [rather obscure] cases.

Assigning a value to

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

59 might not result in an accurate label within process manager applications such as macOS Activity Monitor or Windows Services Manager.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

69

Added in: v0.8.0

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

69 property indicates whether the

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

24 flag is set on the current Node.js process. See the documentation for the and the for more information about this flag's behavior.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

74

- Deprecated. Calling

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

74 with no argument causes the process-wide umask to be written twice. This introduces a race condition between threads, and is a potential security vulnerability. There is no safe, cross-platform alternative API.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

74 returns the Node.js process's file mode creation mask. Child processes inherit the mask from the parent process.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

77

Added in: v0.1.19

  • import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] 78 |

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

77 sets the Node.js process's file mode creation mask. Child processes inherit the mask from the parent process. Returns the previous mask.

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

0

In threads,

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

77 will throw an exception.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

82

Added in: v0.5.0

  • Returns:

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

82 method returns the number of seconds the current Node.js process has been running.

The return value includes fractions of a second. Use

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

84 to get whole seconds.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

85

Added in: v0.1.3

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

85 property contains the Node.js version string.

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

1

To get the version string without the prepended v, use

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

87.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

88

The

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

88 property returns an object listing the version strings of Node.js and its dependencies.

import process from 'node:process'; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[] const process = require['node:process']; process.on['unhandledRejection', [reason, promise] => { console.log['Unhandled Rejection at:', promise, 'reason:', reason]; // Application specific logging, throwing an error, or other logic here }]; somePromise.then[[res] => { return reportToUser[JSON.pasre[res]]; // Note the typo [pasre] }]; // No .catch[] or .then[]

90 indicates the current ABI version, which is increased whenever a C++ API changes. Node.js will refuse to load modules that were compiled against a different module ABI version.

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

2

Will generate an object similar to:

import process from 'node:process'; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn const process = require['node:process']; function SomeResource[] { // Initially set the loaded status to a rejected promise this.loaded = Promise.reject[new Error['Resource not yet loaded!']]; } const resource = new SomeResource[]; // no .catch or .then on resource.loaded for at least a turn

3

Exit codes

Node.js will normally exit with a

import process from 'node:process'; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }]; const process = require['node:process']; process.on['exit', [code] => { console.log[About to exit with code: ${code}]; }];

71 status code when no more async operations are pending. The following status codes are used in other cases:

Chủ Đề