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 committed Aug 6, 2020
1 parent 4824988 commit a4e1755
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 @@ -313,8 +313,8 @@ class AsyncLocalStorage {
}

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

0 comments on commit a4e1755

Please sign in to comment.