Skip to content

Commit

Permalink
src: remove unused PromiseWrap-related code
Browse files Browse the repository at this point in the history
PromiseWrap has been removed in
#39135 and we do not have any
internal object setting the internal field at 0 as a promise
(we always set the first field as an aligned pointer to
the embedder ID). As result GetAssignedPromiseWrapAsyncId()
always just returns AsyncWrap::kInvalidAsyncId and turn
the removed block into noops. So the block just can be removed.

PR-URL: #49335
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
  • Loading branch information
joyeecheung authored and UlisesGascon committed Sep 10, 2023
1 parent ef3d8dd commit 701c46f
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/node_task_queue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,6 @@ static Maybe<double> GetAssignedPromiseAsyncId(Environment* env,
: v8::Just(AsyncWrap::kInvalidAsyncId);
}

static Maybe<double> GetAssignedPromiseWrapAsyncId(Environment* env,
Local<Promise> promise,
Local<Value> id_symbol) {
// This check is imperfect. If the internal field is set, it should
// be an object. If it's not, we just ignore it. Ideally v8 would
// have had GetInternalField returning a MaybeLocal but this works
// for now.
Local<Value> promiseWrap = promise->GetInternalField(0).As<Value>();
if (promiseWrap->IsObject()) {
Local<Value> maybe_async_id;
if (!promiseWrap.As<Object>()->Get(env->context(), id_symbol)
.ToLocal(&maybe_async_id)) {
return v8::Just(AsyncWrap::kInvalidAsyncId);
}
return maybe_async_id->IsNumber()
? maybe_async_id->NumberValue(env->context())
: v8::Just(AsyncWrap::kInvalidAsyncId);
} else {
return v8::Just(AsyncWrap::kInvalidAsyncId);
}
}

void PromiseRejectCallback(PromiseRejectMessage message) {
static std::atomic<uint64_t> unhandledRejections{0};
static std::atomic<uint64_t> rejectionsHandledAfter{0};
Expand Down Expand Up @@ -122,17 +100,6 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
if (!GetAssignedPromiseAsyncId(env, promise, env->trigger_async_id_symbol())
.To(&trigger_async_id)) return;

if (async_id == AsyncWrap::kInvalidAsyncId &&
trigger_async_id == AsyncWrap::kInvalidAsyncId) {
// That means that promise might be a PromiseWrap, so we'll
// check there as well.
if (!GetAssignedPromiseWrapAsyncId(env, promise, env->async_id_symbol())
.To(&async_id)) return;
if (!GetAssignedPromiseWrapAsyncId(
env, promise, env->trigger_async_id_symbol())
.To(&trigger_async_id)) return;
}

if (async_id != AsyncWrap::kInvalidAsyncId &&
trigger_async_id != AsyncWrap::kInvalidAsyncId) {
env->async_hooks()->push_async_context(
Expand Down

0 comments on commit 701c46f

Please sign in to comment.