mapbox / mapbox/node-cpp-skel

try/catch in HandleOKCallback

Open
#114 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
C++
Stars
74
Forks
9
PR merge metrics
No merged PRs in 30d

Description

We should add try/catch around code in the HandleOKCallback like https://github.com/mapbox/node-cpp-skel/blob/c3d13e76cfb1178c92bf8beca822da4aba8c28f7/src/object_async/hello_async.cpp#L179-L186. 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 https://github.com/mapbox/vtquery/issues/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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced src/object_async/hello_async.cpp example, especially lines 179-186, and locate HandleOKCallback in node-cpp-skel. Add the requested exception handling around its callback code, then verify that downstream exceptions are caught rather than aborting the process.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, node.js
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.