-
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
errors: should we raise assersions for type checks in process.bindings? #17244
Comments
cc @nodejs/tsc @jasnell |
I'm OK with this. |
Squashed from multiple commits: - src: replace ->To*(isolate) with ->To*(context).ToLocalChecked() - test: use .As<Object> on Exception::Error > Exception::Error always returns an object, so e.As<Object>() should also work fine See #17343 (comment) - test: use .As<Object> instead of ->ToObject we already checked that its a buffer - src: use FromMaybe instead of ToLocalChecked It fixed this test case: 19a1b2e - src: pass context to Get() Dont pass Local<Context> is deprecated soon. So we migrate to maybe version. - src: return if Get or ToObject return an empty before call ToLocalChecked Refs: #17244 PR-URL: #17343 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
I'm ok with this. Nit: there's a |
I'm generally ok, the only concern is if this will cause significant breakage for existing users. I guess though that in either case they would have been doing something incorrect and my first guess is that there should not be too much code catching the error and just continuing. |
Would it make sense to do an initial naive implementation and run that against citgm? |
@MylesBorins I think #17334 pretty much handles most of the type check migration |
I am 👍 with the approach, independently off the breakage. |
Squashed from multiple commits: - src: replace ->To*(isolate) with ->To*(context).ToLocalChecked() - test: use .As<Object> on Exception::Error > Exception::Error always returns an object, so e.As<Object>() should also work fine See #17343 (comment) - test: use .As<Object> instead of ->ToObject we already checked that its a buffer - src: use FromMaybe instead of ToLocalChecked It fixed this test case: 19a1b2e - src: pass context to Get() Dont pass Local<Context> is deprecated soon. So we migrate to maybe version. - src: return if Get or ToObject return an empty before call ToLocalChecked Refs: #17244 PR-URL: #17343 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Squashed from multiple commits: - src: replace ->To*(isolate) with ->To*(context).ToLocalChecked() - test: use .As<Object> on Exception::Error > Exception::Error always returns an object, so e.As<Object>() should also work fine See #17343 (comment) - test: use .As<Object> instead of ->ToObject we already checked that its a buffer - src: use FromMaybe instead of ToLocalChecked It fixed this test case: 19a1b2e - src: pass context to Get() Dont pass Local<Context> is deprecated soon. So we migrate to maybe version. - src: return if Get or ToObject return an empty before call ToLocalChecked Refs: #17244 PR-URL: #17343 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
This can be closed now since #17334 has landed |
To migrate the errors thrown in C++ land we currently try to collect the context in C++ then throw the actual errors in JS using utilities in
internal/errors.js
. The current pattern would replace code likewith
CHECK(args.Length() >= 1);
and enforce the type checks with
->To*(context).ToLocalChecked()
.The JS layer would do the checks in advance and make sure the bindings are invoked correctly, but if there are people using
process.bindings()
with wrong types of objects, previously they got errors, now they would get assersions.This issues is to make sure we are OK with this path forward. Otherwise we need to somehow port the stuff in
internal/errors.js
back to C++ land for migrating those errors.The text was updated successfully, but these errors were encountered: