From 896f6551306dd873de349836b9dfb5888593f7db Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Wed, 1 Jun 2016 12:33:33 -0600 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/7048 PR-URL: https://github.com/nodejs/node/pull/7096 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Andreas Madsen --- src/async-wrap-inl.h | 6 +++--- src/async-wrap.cc | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index cf7024e7e31461..9f520de4429622 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -40,14 +40,14 @@ inline AsyncWrap::AsyncWrap(Environment* env, v8::HandleScope scope(env->isolate()); v8::Local argv[] = { - v8::Integer::New(env->isolate(), get_uid()), + v8::Number::New(env->isolate(), get_uid()), v8::Int32::New(env->isolate(), provider), Null(env->isolate()), Null(env->isolate()) }; if (parent != nullptr) { - argv[2] = v8::Integer::New(env->isolate(), parent->get_uid()); + argv[2] = v8::Number::New(env->isolate(), parent->get_uid()); argv[3] = parent->object(); } @@ -72,7 +72,7 @@ inline AsyncWrap::~AsyncWrap() { v8::Local fn = env()->async_hooks_destroy_function(); if (!fn.IsEmpty()) { v8::HandleScope scope(env()->isolate()); - v8::Local uid = v8::Integer::New(env()->isolate(), get_uid()); + v8::Local uid = v8::Number::New(env()->isolate(), get_uid()); v8::TryCatch try_catch(env()->isolate()); v8::MaybeLocal ret = fn->Call(env()->context(), v8::Null(env()->isolate()), 1, &uid); diff --git a/src/async-wrap.cc b/src/async-wrap.cc index 8129500a922d97..2b6839c05ee461 100644 --- a/src/async-wrap.cc +++ b/src/async-wrap.cc @@ -19,6 +19,7 @@ using v8::Integer; using v8::Isolate; using v8::Local; using v8::MaybeLocal; +using v8::Number; using v8::Object; using v8::RetainedObjectInfo; using v8::TryCatch; @@ -198,7 +199,7 @@ Local AsyncWrap::MakeCallback(const Local cb, Local pre_fn = env()->async_hooks_pre_function(); Local post_fn = env()->async_hooks_post_function(); - Local uid = Integer::New(env()->isolate(), get_uid()); + Local uid = Number::New(env()->isolate(), get_uid()); Local context = object(); Local domain; bool has_domain = false;