• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('assert');
4const { promiseHooks } = require('v8');
5
6assert.throws(() => {
7  promiseHooks.onAfter(async function() { });
8}, /The "afterHook" argument must be of type function/);
9
10assert.throws(() => {
11  promiseHooks.onAfter(async function*() { });
12}, /The "afterHook" argument must be of type function/);
13
14let seen;
15
16const stop = promiseHooks.onAfter(common.mustCall((promise) => {
17  seen = promise;
18}, 1));
19
20const promise = Promise.resolve().then(() => {
21  assert.strictEqual(seen, undefined);
22});
23
24promise.then(() => {
25  assert.strictEqual(seen, promise);
26  stop();
27});
28
29assert.strictEqual(seen, undefined);
30