Skip to content
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

try/catch in HandleOKCallback #114

Open
springmeyer opened this issue Apr 4, 2018 · 0 comments
Open

try/catch in HandleOKCallback #114

springmeyer opened this issue Apr 4, 2018 · 0 comments

Comments

@springmeyer
Copy link
Contributor

We should add try/catch around code in the HandleOKCallback like

Nan::HandleScope scope;
const auto argc = 2u;
v8::Local<v8::Value> argv[argc] = {
Nan::Null(), Nan::New<v8::String>(result_).ToLocalChecked()};
// Static cast done here to avoid 'cppcoreguidelines-pro-bounds-array-to-pointer-decay' warning with clang-tidy
callback->Call(argc, static_cast<v8::Local<v8::Value>*>(argv));
. Otherwise down stream developers are likely to:

  • add new code to the HandleOKCallback
  • in many instances that code might throw
  • a throw will not be caught automatically and will instead crash the process with an abort

An example is mapbox/vtquery#69 /cc @mapsam

We must protect against crashes like this, so I think its worth adding try/catch around the code in node-cpp-skel. Then users would be forced (due to the lack of coverage of the catch to think hard about whether an exception is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant