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 mcollina committed Apr 2, 2020
1 parent b149eef commit 7e664a5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions benchmark/async_hooks/async-resource-vs-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,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 @@ -116,11 +113,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 7e664a5

Please sign in to comment.