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 <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Flarna authored and addaleax committed Sep 22, 2020
1 parent 3b672bb commit 5c51c70
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 5c51c70

Please sign in to comment.