xref: /third_party/node/test/async-hooks/test-disable-in-init.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/async-hooks/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks');
51cb0ef41Sopenharmony_ciconst fs = require('fs');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cilet nestedCall = false;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciasync_hooks.createHook({
101cb0ef41Sopenharmony_ci  init: common.mustCall(() => {
111cb0ef41Sopenharmony_ci    nestedHook.disable();
121cb0ef41Sopenharmony_ci    if (!nestedCall) {
131cb0ef41Sopenharmony_ci      nestedCall = true;
141cb0ef41Sopenharmony_ci      fs.access(__filename, common.mustCall());
151cb0ef41Sopenharmony_ci    }
161cb0ef41Sopenharmony_ci  }, 2),
171cb0ef41Sopenharmony_ci}).enable();
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst nestedHook = async_hooks.createHook({
201cb0ef41Sopenharmony_ci  init: common.mustCall(2),
211cb0ef41Sopenharmony_ci}).enable();
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cifs.access(__filename, common.mustCall());
24

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