Skip to content

Commit

Permalink
benchmark: fix error on server close in AsyncLocalStorage benchmark
Browse files Browse the repository at this point in the history
PR-URL: #32503
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
puzpuzpuz authored and targos committed Apr 28, 2020
1 parent 2508e13 commit 3861c69
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions benchmark/async_hooks/async-resource-vs-destroy.js
Expand Up @@ -37,17 +37,14 @@ function buildCurrentResource(getServe) {

function getCLS() {
const resource = executionAsyncResource();
if (resource === null || !resource[cls]) {
if (!resource[cls]) {
return null;
}
return resource[cls].state;
}

function setCLS(state) {
const resource = executionAsyncResource();
if (resource === null) {
return;
}
if (!resource[cls]) {
resource[cls] = { state };
} else {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3861c69

Please sign in to comment.