Skip to content

Commit 271927f

Browse files
trevnorrisMyles Borins
authored and
Myles Borins
committed
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. Ref: #7048 PR-URL: #7096 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Andreas Madsen <[email protected]>
1 parent 747f107 commit 271927f

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
@@ -40,14 +40,14 @@ inline AsyncWrap::AsyncWrap(Environment* env,
4040
v8::HandleScope scope(env->isolate());
4141

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

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

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

src/async-wrap.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using v8::Integer;
1919
using v8::Isolate;
2020
using v8::Local;
2121
using v8::MaybeLocal;
22+
using v8::Number;
2223
using v8::Object;
2324
using v8::RetainedObjectInfo;
2425
using v8::TryCatch;
@@ -198,7 +199,7 @@ Local<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
198199

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

0 commit comments

Comments
 (0)