Files
node/test/parallel/test-mark-promise-handled.js
James M Snell 8fb89abb8d src,lib: add util.markPromiseAsHandled
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65805
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
2026-09-07 11:42:09 +00:00

26 lines
549 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('node:assert');
const { markPromiseAsHandled } = require('node:util');
process.on('unhandledRejection', common.mustNotCall());
markPromiseAsHandled(Promise.reject(123));
{
const { promise, reject } = Promise.withResolvers();
markPromiseAsHandled(promise);
reject(123);
}
{
const { promise, reject } = Promise.withResolvers();
reject(123);
markPromiseAsHandled(promise);
}
assert.throws(() => markPromiseAsHandled(123), {
code: 'ERR_INVALID_ARG_TYPE',
});