Skip to content

Commit 701c46f

Browse files
joyeecheungUlisesGascon
authored andcommitted
src: remove unused PromiseWrap-related code
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 <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent ef3d8dd commit 701c46f

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

src/node_task_queue.cc

-33
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,6 @@ static Maybe<double> GetAssignedPromiseAsyncId(Environment* env,
4343
: v8::Just(AsyncWrap::kInvalidAsyncId);
4444
}
4545

46-
static Maybe<double> GetAssignedPromiseWrapAsyncId(Environment* env,
47-
Local<Promise> promise,
48-
Local<Value> id_symbol) {
49-
// This check is imperfect. If the internal field is set, it should
50-
// be an object. If it's not, we just ignore it. Ideally v8 would
51-
// have had GetInternalField returning a MaybeLocal but this works
52-
// for now.
53-
Local<Value> promiseWrap = promise->GetInternalField(0).As<Value>();
54-
if (promiseWrap->IsObject()) {
55-
Local<Value> maybe_async_id;
56-
if (!promiseWrap.As<Object>()->Get(env->context(), id_symbol)
57-
.ToLocal(&maybe_async_id)) {
58-
return v8::Just(AsyncWrap::kInvalidAsyncId);
59-
}
60-
return maybe_async_id->IsNumber()
61-
? maybe_async_id->NumberValue(env->context())
62-
: v8::Just(AsyncWrap::kInvalidAsyncId);
63-
} else {
64-
return v8::Just(AsyncWrap::kInvalidAsyncId);
65-
}
66-
}
67-
6846
void PromiseRejectCallback(PromiseRejectMessage message) {
6947
static std::atomic<uint64_t> unhandledRejections{0};
7048
static std::atomic<uint64_t> rejectionsHandledAfter{0};
@@ -122,17 +100,6 @@ void PromiseRejectCallback(PromiseRejectMessage message) {
122100
if (!GetAssignedPromiseAsyncId(env, promise, env->trigger_async_id_symbol())
123101
.To(&trigger_async_id)) return;
124102

125-
if (async_id == AsyncWrap::kInvalidAsyncId &&
126-
trigger_async_id == AsyncWrap::kInvalidAsyncId) {
127-
// That means that promise might be a PromiseWrap, so we'll
128-
// check there as well.
129-
if (!GetAssignedPromiseWrapAsyncId(env, promise, env->async_id_symbol())
130-
.To(&async_id)) return;
131-
if (!GetAssignedPromiseWrapAsyncId(
132-
env, promise, env->trigger_async_id_symbol())
133-
.To(&trigger_async_id)) return;
134-
}
135-
136103
if (async_id != AsyncWrap::kInvalidAsyncId &&
137104
trigger_async_id != AsyncWrap::kInvalidAsyncId) {
138105
env->async_hooks()->push_async_context(

0 commit comments

Comments
 (0)