-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: remove calls to deprecated v8 functions (ToString) #21935
Conversation
Testing locally, but what we have: not ok 1381 parallel/test-process-env-symbols
---
duration_ms: 0.413
severity: crashed
exitcode: -6
stack: |-
FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
1: 0x834fe0 node::Abort() [out/Release/node]
2: 0x8351d2 [out/Release/node]
3: 0x9dc661 v8::V8::ToLocalEmpty() [out/Release/node]
4: 0x837aef [out/Release/node]
5: 0xded05e v8::internal::PropertyCallbackArguments::CallNamedSetter(v8::internal::Handle<v8::internal::InterceptorInfo>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>) [out/Release/node]
6: 0xe7500a [out/Release/node]
7: 0xe8439f v8::internal::Object::SetPropertyInternal(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode, v8::internal::Object::StoreFromKeyed, bool*) [out/Release/node]
8: 0xe84237 v8::internal::Object::SetProperty(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>, v8::internal::LanguageMode, v8::internal::Object::StoreFromKeyed) [out/Release/node]
9: 0xde338c v8::internal::StoreIC::Store(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Object>, v8::internal::Object::StoreFromKeyed) [out/Release/node]
10: 0xde5365 v8::internal::KeyedStoreIC::Store(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [out/Release/node]
11: 0xde92e7 v8::internal::Runtime_KeyedStoreIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [out/Release/node]
12: 0x9e04e8841bd
... Looks related? |
Okay, one of the @addaleax good enough opportunity to add error checking for each |
@ryzokuken Yes, as far as I can tell, all of these can fail. We do need proper error handling here rather than using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a bunch of nits
src/node_crypto.cc
Outdated
if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8)) | ||
bool result; | ||
if (!decoder.Decode(env, args[0].As<String>(), args[1], UTF8).To(&result) || | ||
!result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: if (!decoder.Decode(…).FromMaybe(false))
also does the trick and is a bit more idiomatic (here and below)
src/node_encoding.cc
Outdated
if (r.IsNothing()) { | ||
return -1; | ||
} | ||
return r.FromJust(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, return StringBytes::Size(…).FromMaybe(-1)
is just as fine
src/spawn_sync.cc
Outdated
if (maybe_r.IsNothing()) { | ||
return v8::Nothing<bool>(); | ||
} | ||
r = maybe_r.FromJust(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!ParseOptions(options).To(&r)) return v8::Nothing<bool>();
?
src/spawn_sync.cc
Outdated
HandleScope scope(env()->isolate()); | ||
int r; | ||
|
||
if (!js_value->IsObject()) | ||
return UV_EINVAL; | ||
return v8::Just(static_cast<int>(UV_EINVAL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v8::Just<int>(UV_EINVAL)
?
src/spawn_sync.cc
Outdated
if (r_file.IsNothing()) { | ||
return v8::Nothing<int>(); | ||
} | ||
r = r_file.FromJust(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto, using .To(&r)
is a bit more succinct
src/util.cc
Outdated
StringBytes::StorageSize(isolate, string, UTF8); | ||
if (maybe_storage.IsNothing()) | ||
return; | ||
const size_t storage = maybe_storage.FromJust() + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and finally, ditto :)
HandleScope scope(env()->isolate()); | ||
int r; | ||
|
||
if (!js_value->IsObject()) | ||
return UV_EINVAL; | ||
return v8::Just<int>(UV_EINVAL); | ||
|
||
Local<Context> context = env()->context(); | ||
Local<Object> js_options = js_value.As<Object>(); | ||
|
||
Local<Value> js_file = | ||
js_options->Get(context, env()->file_string()).ToLocalChecked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, I know that you are a huuuuge fan of PR scope creep, but ... feel free to take care of other such places in the functions you're already touching as well, if you like?
This needs a rebase. Apart from that, is it ready? |
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only).
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities.
eef4819
to
d096c49
Compare
Rebased, fixed conflicts and added |
Note: I also recreated the commits to apply |
Ping. CI is green |
@addaleax also this one :) |
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::ToString) inside the code (src directory only). PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Rework all affected functions to use Maybes, thus improving error handling substantially in internal functions, API functions as well as utilities. Co-authored-by: Michaël Zasso <targos@protonmail.com> PR-URL: #21935 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Remove all calls to deprecated v8 functions (here: Value::ToString) inside
the code (src directory only).
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes/cc @hashseed