From a4e1755df2f9bb8c712d7ca767a5944d9d71e33b 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 <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> --- 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 9438f27897b590..758c4eab10fe83 100644 --- a/lib/async_hooks.js +++ b/lib/async_hooks.js @@ -313,8 +313,8 @@ class AsyncLocalStorage { } getStore() { - const resource = executionAsyncResource(); if (this.enabled) { + const resource = executionAsyncResource(); return resource[this.kResourceStore]; } }