Skip to content

Commit

Permalink
async_hooks: don't read resource if ALS is disabled
Browse files Browse the repository at this point in the history
Only call executionAsyncResource() in getStore() if the ALS instance is
enabled because the resource is not needed otherwise.

PR-URL: #34617
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Flarna authored and codebytere committed Aug 11, 2020
1 parent 221802d commit 4dbb931
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class AsyncLocalStorage {
}

getStore() {
const resource = executionAsyncResource();
if (this.enabled) {
const resource = executionAsyncResource();
return resource[this.kResourceStore];
}
}
Expand Down

0 comments on commit 4dbb931

Please sign in to comment.