Skip to content

Commit 78b90d9

Browse files
puzpuzpuztargos
authored andcommitted
benchmark: fix error on server close in AsyncLocalStorage benchmark
PR-URL: #32503 Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 8597df4 commit 78b90d9

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
@@ -35,17 +35,14 @@ function buildCurrentResource(getServe) {
3535

3636
function getCLS() {
3737
const resource = executionAsyncResource();
38-
if (resource === null || !resource[cls]) {
38+
if (!resource[cls]) {
3939
return null;
4040
}
4141
return resource[cls].state;
4242
}
4343

4444
function setCLS(state) {
4545
const resource = executionAsyncResource();
46-
if (resource === null) {
47-
return;
48-
}
4946
if (!resource[cls]) {
5047
resource[cls] = { state };
5148
} else {
@@ -116,11 +113,17 @@ function buildAsyncLocalStorage(getServe) {
116113

117114
function getCLS() {
118115
const store = asyncLocalStorage.getStore();
116+
if (store === undefined) {
117+
return null;
118+
}
119119
return store.state;
120120
}
121121

122122
function setCLS(state) {
123123
const store = asyncLocalStorage.getStore();
124+
if (store === undefined) {
125+
return;
126+
}
124127
store.state = state;
125128
}
126129

0 commit comments

Comments
 (0)