async_hooks: add sync enterWith to async storage by Qard · Pull Request #31945 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions doc/api/async_hooks.md
6 changes: 3 additions & 3 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class AsyncLocalStorage {
}
}

_enter(store) {
enterWith(store) {
if (!this.enabled) {
this.enabled = true;
storageList.push(this);
Expand All @@ -258,7 +258,7 @@ class AsyncLocalStorage {
runSyncAndReturn(store, callback, ...args) {
const resource = executionAsyncResource();
const outerStore = resource[this.kResourceStore];
this._enter(store);
this.enterWith(store);
try {
return callback(...args);
} finally {
Expand Down Expand Up @@ -288,7 +288,7 @@ class AsyncLocalStorage {
run(store, callback, ...args) {
const resource = executionAsyncResource();
const outerStore = resource[this.kResourceStore];
this._enter(store);
this.enterWith(store);
process.nextTick(callback, ...args);
resource[this.kResourceStore] = outerStore;
}
Expand Down
20 changes: 20 additions & 0 deletions test/async-hooks/test-async-local-storage-enter-with.js