async_hooks: fix context loss after nested calls to AsyncLocalStorage
Fixes the following issues within AsyncLocalStorage
API:
- Nested calls to
run*
were erasing the outer store, leading to context loss.- Note:
test-async-local-storage-nested.js
was updated to validate this fix, as its previous contents were a partial duplicate oftest-async-local-storage-no-mix-contexts.js
- Note:
- Calls to
exit*
were switchingenabled
field totrue
without checking current value. This leads to incorrect behavior of furthergetStore
andrun*
calls.
These issues were discussed in #31950, but as that PR involves significant changes in implementation and will require some time to settle down.
cc @vdeturckheim @Qard @Flarna
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines