1'use strict'; 2require('../common'); 3const assert = require('assert'); 4const async_hooks = require('async_hooks'); 5 6// This test verifies that the async ID stack can grow indefinitely. 7 8function recurse(n) { 9 const a = new async_hooks.AsyncResource('foobar'); 10 a.runInAsyncScope(() => { 11 assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); 12 assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); 13 if (n >= 0) 14 recurse(n - 1); 15 assert.strictEqual(a.asyncId(), async_hooks.executionAsyncId()); 16 assert.strictEqual(a.triggerAsyncId(), async_hooks.triggerAsyncId()); 17 }); 18} 19 20recurse(1000); 21