promiseHooks.onInit(init)
init
<Function> Theinit
callback to call when a promise is created.- Returns: <Function> Call to stop the hook.
The init
hook must be a plain function. Providing an async function will
throw as it would produce an infinite microtask loop.
import { promiseHooks } from 'node:v8';
const stop = promiseHooks.onInit((promise, parent) => {});
const { promiseHooks } = require('node:v8');
const stop = promiseHooks.onInit((promise, parent) => {});