Skip to content

Commit 3861c69

Browse files
puzpuzpuztargos
authored andcommitted
benchmark: fix error on server close in AsyncLocalStorage benchmark
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>
1 parent 2508e13 commit 3861c69

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

benchmark/async_hooks/async-resource-vs-destroy.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ function buildCurrentResource(getServe) {
3737

3838
function getCLS() {
3939
const resource = executionAsyncResource();
40-
if (resource === null || !resource[cls]) {
40+
if (!resource[cls]) {
4141
return null;
4242
}
4343
return resource[cls].state;
4444
}
4545

4646
function setCLS(state) {
4747
const resource = executionAsyncResource();
48-
if (resource === null) {
49-
return;
50-
}
5148
if (!resource[cls]) {
5249
resource[cls] = { state };
5350
} else {
@@ -118,11 +115,17 @@ function buildAsyncLocalStorage(getServe) {
118115

119116
function getCLS() {
120117
const store = asyncLocalStorage.getStore();
118+
if (store === undefined) {
119+
return null;
120+
}
121121
return store.state;
122122
}
123123

124124
function setCLS(state) {
125125
const store = asyncLocalStorage.getStore();
126+
if (store === undefined) {
127+
return;
128+
}
126129
store.state = state;
127130
}
128131

0 commit comments

Comments
 (0)