Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,11 @@ function hasAsyncIdStack() {
// This is the equivalent of the native push_async_ids() call.
function pushAsyncContext(asyncId, triggerAsyncId, resource) {
const offset = async_hook_fields[kStackLength];
execution_async_resources[offset] = resource;
if (offset * 2 >= async_wrap.async_ids_stack.length)
return pushAsyncContext_(asyncId, triggerAsyncId, resource);
async_wrap.async_ids_stack[offset * 2] = async_id_fields[kExecutionAsyncId];
async_wrap.async_ids_stack[offset * 2 + 1] = async_id_fields[kTriggerAsyncId];
execution_async_resources[offset] = resource;
async_hook_fields[kStackLength]++;
async_id_fields[kExecutionAsyncId] = asyncId;
async_id_fields[kTriggerAsyncId] = triggerAsyncId;
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-async-local-storage-deep-stack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
const common = require('../common');
const { AsyncLocalStorage } = require('async_hooks');

// Regression test for: https://github.com/nodejs/node/issues/34556

const als = new AsyncLocalStorage();

const done = common.mustCall();

function run(count) {
if (count !== 0) return als.run({}, run, --count);
done();
}
run(1000);