Title: Node-API: async-work complete callback runs without an entered context · Issue #441 · NativeScript/ios · GitHub
Open Graph Title: Node-API: async-work complete callback runs without an entered context · Issue #441 · NativeScript/ios
X Title: Node-API: async-work complete callback runs without an entered context · Issue #441 · NativeScript/ios
Description: Found while porting #437 to Android (NativeScript/android#2004) by an independent review of the port; the defect is shared with the iOS original. CompleteAsyncWork in NativeScript/napi/NodeApiEmbed.mm calls env->CallIntoModule(...) with ...
Open Graph Description: Found while porting #437 to Android (NativeScript/android#2004) by an independent review of the port; the defect is shared with the iOS original. CompleteAsyncWork in NativeScript/napi/NodeApiEmbed...
X Description: Found while porting #437 to Android (NativeScript/android#2004) by an independent review of the port; the defect is shared with the iOS original. CompleteAsyncWork in NativeScript/napi/NodeApiEmbed...
Opengraph URL: https://github.com/NativeScript/ios/issues/441
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Node-API: async-work complete callback runs without an entered context","articleBody":"Found while porting #437 to Android (NativeScript/android#2004) by an independent review of the port; the defect is shared with the iOS original.\n\n`CompleteAsyncWork` in `NativeScript/napi/NodeApiEmbed.mm` calls `env->CallIntoModule(...)` with no `v8::Context::Scope` (and no `HandleScope` of its own) — the event-loop entry it runs in supplies only Locker + Isolate::Scope + HandleScope. Every sibling entry path opens the context scope itself (`NapiEnv::CallFinalizer`, the TSFN dispatch in `NapiThreadSafeFunction.mm`), but the async-work completion path does not.\n\nConsequences:\n\n- Node guarantees the `complete` callback runs with the env's context entered; addon code that touches the engine directly (or any napi call that reads `isolate->GetCurrentContext()`) observes an empty current context.\n- If the complete callback throws JS-side (e.g. the documented `napi_throw_error` failure-reporting pattern), the exception handler runs against an empty current context — on the Android port this was a null-deref/CHECK crash in the error reporter; the iOS reporter may or may not survive it, but the contract violation is the same.\n\nFix is the same one-liner the Android port applied in review: open `v8::HandleScope` + `v8::Context::Scope(env->context())` in `CompleteAsyncWork` before `CallIntoModule`, mirroring `NapiEnv::CallFinalizer`.\n\nAndroid-side fix: NativeScript/android#2004 (`CompleteAsyncWork` in `test-app/runtime/src/main/cpp/napi/NodeApiEmbed.cpp`).","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-08-13T17:14:06Z","url":"https://github.com/NativeScript/ios/issues/441"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8f2b21cc-a5d6-1f49-eefd-13f9c8e01b69 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B24E:DB09F:176F0E1:1DE8A51:6B0141F0 |
| html-safe-nonce | 5ea8118e2406c9aae71c910ea061cf056bec905cda80aadaa3229c3ad7da3c27 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjRFOkRCMDlGOjE3NkYwRTE6MURFOEE1MTo2QjAxNDFGMCIsInZpc2l0b3JfaWQiOiI4MTM5MzQ4OTM0ODIxNzU3NDI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9132db12c8993836771fb4d700eccfe043d3a8c9e140f92a7822de57a639024d |
| hovercard-subject-tag | issue:5143944258 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/ios/441/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afcd297eb70c85463e7715ac943b36963d26a98c463b0fea10b9da3b3c576917/NativeScript/ios/issues/441 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afcd297eb70c85463e7715ac943b36963d26a98c463b0fea10b9da3b3c576917/NativeScript/ios/issues/441 |
| og:image:alt | Found while porting #437 to Android (NativeScript/android#2004) by an independent review of the port; the defect is shared with the iOS original. CompleteAsyncWork in NativeScript/napi/NodeApiEmbed... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edusperoni |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/ios git https://github.com/NativeScript/ios.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 172934359 |
| octolytics-dimension-repository_nwo | NativeScript/ios |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172934359 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/ios |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width