Skip to content

Create napi safe wrap#182

Merged
dajimenezriv-internxt merged 1 commit into
masterfrom
create-napi-safe-wrap
Aug 26, 2025
Merged

Create napi safe wrap#182
dajimenezriv-internxt merged 1 commit into
masterfrom
create-napi-safe-wrap

Conversation

@dajimenezriv-internxt
Copy link
Copy Markdown
Contributor

@dajimenezriv-internxt dajimenezriv-internxt commented Aug 15, 2025

What

This PR creates a function napi_safe_wrap that is going to wrap all calls from javascript to C++. Why? If we throw an exception in C++ that is not handled successfully it breaks the javascript process. So, we create a wrapper that catches any exception and returns a valid javascript error.

@dajimenezriv-internxt dajimenezriv-internxt self-assigned this Aug 15, 2025
napi_create_int32(env, static_cast<int32_t>(result), &napiResult);
return napiResult;
napi_value RegisterSyncRootWrapper(napi_env env, napi_callback_info info) {
return napi_safe_wrap(env, info, register_sync_root_impl);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are wrapping the register sync root function.

@dajimenezriv-internxt dajimenezriv-internxt merged commit d39d220 into master Aug 26, 2025
1 check passed
@dajimenezriv-internxt dajimenezriv-internxt deleted the create-napi-safe-wrap branch August 26, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants