From 5c51c70732bb93f56243da9fc165ee57d7cf8590 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Mon, 3 Aug 2020 23:52:58 +0200 Subject: [PATCH] async_hooks: don't read resource if ALS is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only call executionAsyncResource() in getStore() if the ALS instance is enabled because the resource is not needed otherwise. PR-URL: https://github.com/nodejs/node/pull/34617 Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/async_hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/async_hooks.js b/lib/async_hooks.js index 0943534790550c..4f7f03c3bf4aff 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -277,8 +277,8 @@ class AsyncLocalStorage { } getStore() { - const resource = executionAsyncResource(); if (this.enabled) { + const resource = executionAsyncResource(); return resource[this.kResourceStore]; } }