mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

PR-URL: https://github.com/nodejs/node/pull/39283 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
30 lines
683 B
JavaScript
30 lines
683 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { promiseHooks } = require('v8');
|
|
|
|
assert.throws(() => {
|
|
promiseHooks.onAfter(async function() { });
|
|
}, /The "afterHook" argument must be of type function/);
|
|
|
|
assert.throws(() => {
|
|
promiseHooks.onAfter(async function*() { });
|
|
}, /The "afterHook" argument must be of type function/);
|
|
|
|
let seen;
|
|
|
|
const stop = promiseHooks.onAfter(common.mustCall((promise) => {
|
|
seen = promise;
|
|
}, 1));
|
|
|
|
const promise = Promise.resolve().then(() => {
|
|
assert.strictEqual(seen, undefined);
|
|
});
|
|
|
|
promise.then(() => {
|
|
assert.strictEqual(seen, promise);
|
|
stop();
|
|
});
|
|
|
|
assert.strictEqual(seen, undefined);
|