11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// This test ensures that fast-path PromiseHook assigns async ids 71cb0ef41Sopenharmony_ci// to already created promises when the native hook function is 81cb0ef41Sopenharmony_ci// triggered on before event. 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_cilet initialAsyncId; 111cb0ef41Sopenharmony_ciconst promise = new Promise((resolve) => { 121cb0ef41Sopenharmony_ci setTimeout(() => { 131cb0ef41Sopenharmony_ci initialAsyncId = async_hooks.executionAsyncId(); 141cb0ef41Sopenharmony_ci async_hooks.createHook({ 151cb0ef41Sopenharmony_ci after: common.mustCall(2) 161cb0ef41Sopenharmony_ci }).enable(); 171cb0ef41Sopenharmony_ci resolve(); 181cb0ef41Sopenharmony_ci }, 0); 191cb0ef41Sopenharmony_ci}); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_cipromise.then(common.mustCall(() => { 221cb0ef41Sopenharmony_ci const id = async_hooks.executionAsyncId(); 231cb0ef41Sopenharmony_ci assert.notStrictEqual(id, initialAsyncId); 241cb0ef41Sopenharmony_ci assert.ok(id > 0); 251cb0ef41Sopenharmony_ci})); 26