xref: /third_party/node/test/parallel/test-async-hooks-disable-during-promise.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciif (!common.isMainThread)
61cb0ef41Sopenharmony_ci  common.skip('Worker bootstrapping works differently -> different AsyncWraps');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst hook = async_hooks.createHook({
91cb0ef41Sopenharmony_ci  init: common.mustCall(2),
101cb0ef41Sopenharmony_ci  before: common.mustCall(1),
111cb0ef41Sopenharmony_ci  after: common.mustNotCall()
121cb0ef41Sopenharmony_ci}).enable();
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciPromise.resolve(1).then(common.mustCall(() => {
151cb0ef41Sopenharmony_ci  hook.disable();
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  Promise.resolve(42).then(common.mustCall());
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci  process.nextTick(common.mustCall());
201cb0ef41Sopenharmony_ci}));
21

Indexes created Thu Nov 07 10:32:03 CST 2024