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 addaleax committed Sep 22, 2020
1 parent 35ff592 commit 61683e1
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 @@ -277,8 +277,8 @@ class AsyncLocalStorage {
}

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

0 comments on commit 61683e1

Please sign in to comment.