Skip to content

Commit e244df5

Browse files
trevnorrisFishrock123
authored andcommitted
async_wrap: pass uid to JS as double
Passing the uid via v8::Integer::New() converts it to a uint32_t. Which will trim the value early. Instead use v8::Number::New() to convert the int64_t to a double so that JS can see the full 2^53 range of uid's. PR-URL: #7096 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
1 parent ef7f016 commit e244df5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/async-wrap-inl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ inline AsyncWrap::AsyncWrap(Environment* env,
4242
v8::HandleScope scope(env->isolate());
4343

4444
v8::Local<v8::Value> argv[] = {
45-
v8::Integer::New(env->isolate(), get_uid()),
45+
v8::Number::New(env->isolate(), get_uid()),
4646
v8::Int32::New(env->isolate(), provider),
4747
Null(env->isolate()),
4848
Null(env->isolate())
4949
};
5050

5151
if (parent != nullptr) {
52-
argv[2] = v8::Integer::New(env->isolate(), parent->get_uid());
52+
argv[2] = v8::Number::New(env->isolate(), parent->get_uid());
5353
argv[3] = parent->object();
5454
}
5555

@@ -74,7 +74,7 @@ inline AsyncWrap::~AsyncWrap() {
7474
v8::Local<v8::Function> fn = env()->async_hooks_destroy_function();
7575
if (!fn.IsEmpty()) {
7676
v8::HandleScope scope(env()->isolate());
77-
v8::Local<v8::Value> uid = v8::Integer::New(env()->isolate(), get_uid());
77+
v8::Local<v8::Value> uid = v8::Number::New(env()->isolate(), get_uid());
7878
v8::TryCatch try_catch(env()->isolate());
7979
v8::MaybeLocal<v8::Value> ret =
8080
fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid);

src/async-wrap.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using v8::Integer;
1818
using v8::Isolate;
1919
using v8::Local;
2020
using v8::MaybeLocal;
21+
using v8::Number;
2122
using v8::Object;
2223
using v8::RetainedObjectInfo;
2324
using v8::TryCatch;
@@ -197,7 +198,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
197198

198199
Local<Function> pre_fn = env()->async_hooks_pre_function();
199200
Local<Function> post_fn = env()->async_hooks_post_function();
200-
Local<Value> uid = Integer::New(env()->isolate(), get_uid());
201+
Local<Value> uid = Number::New(env()->isolate(), get_uid());
201202
Local<Object> context = object();
202203
Local<Object> domain;
203204
bool has_domain = false;

0 commit comments

Comments
 (0)