diff --git a/benchmark/async_hooks/async-resource-vs-destroy.js b/benchmark/async_hooks/async-resource-vs-destroy.js index c9b9a81c5b7c7f..2d0bb74d57a6f9 100644 --- a/benchmark/async_hooks/async-resource-vs-destroy.js +++ b/benchmark/async_hooks/async-resource-vs-destroy.js @@ -37,7 +37,7 @@ function buildCurrentResource(getServe) { function getCLS() { const resource = executionAsyncResource(); - if (resource === null || !resource[cls]) { + if (!resource[cls]) { return null; } return resource[cls].state; @@ -45,9 +45,6 @@ function buildCurrentResource(getServe) { function setCLS(state) { const resource = executionAsyncResource(); - if (resource === null) { - return; - } if (!resource[cls]) { resource[cls] = { state }; } else { @@ -118,11 +115,17 @@ function buildAsyncLocalStorage(getServe) { function getCLS() { const store = asyncLocalStorage.getStore(); + if (store === undefined) { + return null; + } return store.state; } function setCLS(state) { const store = asyncLocalStorage.getStore(); + if (store === undefined) { + return; + } store.state = state; }