11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci// This test verifies that the async ID stack can grow indefinitely. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cifunction recurse(n) { 91cb0ef41Sopenharmony_ci const a = new async_hooks.AsyncResource('foobar'); 101cb0ef41Sopenharmony_ci a.runInAsyncScope(() => { 111cb0ef41Sopenharmony_ci assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); 121cb0ef41Sopenharmony_ci assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); 131cb0ef41Sopenharmony_ci if (n >= 0) 141cb0ef41Sopenharmony_ci recurse(n - 1); 151cb0ef41Sopenharmony_ci assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); 161cb0ef41Sopenharmony_ci assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); 171cb0ef41Sopenharmony_ci }); 181cb0ef41Sopenharmony_ci} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cirecurse(1000); 21