Skip to content

Commit

Permalink
Do not push promise resource on init
Browse files Browse the repository at this point in the history
This means the sync executor or sync start of an async function
will have the same execution async resource as the caller
which may result in unexpected behaviour but it is likely better
than hijacking the rest of the sync context with the promise
as the current execution async resource.
  • Loading branch information
Qard committed Dec 21, 2019
1 parent 6b12f77 commit cd2b24e
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,9 @@ static void PromiseHook(PromiseHookType type, Local<Promise> promise,
wrap = PromiseWrap::New(env, promise, parent_wrap, silent);
} else {
wrap = PromiseWrap::New(env, promise, nullptr, silent);

// needed for async functions :/
// the top level will not emit before and after
env->async_hooks()->push_execution_async_resource(wrap->object());
}
}

if (type == PromiseHookType::kResolve && !parent->IsPromise()) {
env->async_hooks()->pop_execution_async_resource();
}

if (wrap == nullptr) return;

if (type == PromiseHookType::kBefore) {
Expand Down

0 comments on commit cd2b24e

Please sign in to comment.