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 c6be79a

Browse filesBrowse files
apapirovskitargos
authored andcommitted
async_hooks: ensure proper handling in runInAsyncScope
We should never try to manually run emitAfter in case of an error, the exception handler will do it for us, if we're going to recover. PR-URL: #30965 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 42ccf22 commit c6be79a
Copy full SHA for c6be79a

File tree

Expand file treeCollapse file tree

1 file changed

+7
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-9
lines changed
Open diff view settings
Collapse file

‎lib/async_hooks.js‎

Copy file name to clipboardExpand all lines: lib/async_hooks.js
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const {
2121
executionAsyncId,
2222
triggerAsyncId,
2323
// Private API
24-
hasAsyncIdStack,
2524
getHookArrays,
2625
enableHooks,
2726
disableHooks,
@@ -172,14 +171,13 @@ class AsyncResource {
172171
runInAsyncScope(fn, thisArg, ...args) {
173172
const asyncId = this[async_id_symbol];
174173
emitBefore(asyncId, this[trigger_async_id_symbol]);
175-
try {
176-
if (thisArg === undefined)
177-
return fn(...args);
178-
return ReflectApply(fn, thisArg, args);
179-
} finally {
180-
if (hasAsyncIdStack())
181-
emitAfter(asyncId);
182-
}
174+
175+
const ret = thisArg === undefined ?
176+
fn(...args) :
177+
ReflectApply(fn, thisArg, args);
178+
179+
emitAfter(asyncId);
180+
return ret;
183181
}
184182

185183
emitDestroy() {

0 commit comments

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