Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfc769b

Browse filesBrowse files
committed
async_hooks: fix resource stack for deep stacks
460c81d introduced a bug where the execution resource was not stored properly if we needed to call into C++ to extend the stack size. Fix that bug by always storing the resource. Refs: #34319 Fixes: #34556 PR-URL: #34573 Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Gus Caplan <me@gus.host>
1 parent a2141d3 commit cfc769b
Copy full SHA for cfc769b

File tree

Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/async_hooks.js‎

Copy file name to clipboardExpand all lines: lib/internal/async_hooks.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ function hasAsyncIdStack() {
434434
// This is the equivalent of the native push_async_ids() call.
435435
function pushAsyncContext(asyncId, triggerAsyncId, resource) {
436436
const offset = async_hook_fields[kStackLength];
437+
execution_async_resources[offset] = resource;
437438
if (offset * 2 >= async_wrap.async_ids_stack.length)
438439
return pushAsyncContext_(asyncId, triggerAsyncId);
439440
async_wrap.async_ids_stack[offset * 2] = async_id_fields[kExecutionAsyncId];
440441
async_wrap.async_ids_stack[offset * 2 + 1] = async_id_fields[kTriggerAsyncId];
441-
execution_async_resources[offset] = resource;
442442
async_hook_fields[kStackLength]++;
443443
async_id_fields[kExecutionAsyncId] = asyncId;
444444
async_id_fields[kTriggerAsyncId] = triggerAsyncId;
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { AsyncLocalStorage } = require('async_hooks');
4+
5+
// Regression test for: https://github.com/nodejs/node/issues/34556
6+
7+
const als = new AsyncLocalStorage();
8+
9+
const done = common.mustCall();
10+
11+
function run(count) {
12+
if (count !== 0) return als.run({}, run, --count);
13+
done();
14+
}
15+
run(1000);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.