Skip to content

benchmark: fix error on server close in AsyncLocalStorage benchmark

Fixes AsyncLocalStorage type from benchmark/async_hooks/async-resource-vs-destroy.js by adding undefined check for the store (CLS context). Before this fix it could fail when the server is closed (and ALS instance is disabled), which may lead to calls to getCLS() method of the benchmark in the following part of the request handling code:

   setTimeout(() => {
      // the server may be already closed when this (and the next one) callback is run
      readFile(__filename, () => {
        res.setHeader('content-type', 'application/json');
        res.end(JSON.stringify({ cls: getCLS() }));
      });
    }, 10);

Other types within the benchmark already had similar checks, so that's why they weren't failing.

  • Also removes redundant checks from executionAsyncResource type. Reason: the final implementation of executionAsyncResource() never returns null.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Merge request reports

Loading