The OnExecute method receives an napi_env argument. However, do NOT use it within this method, as it does not run on the JavaScript thread and must not run any method that would cause JavaScript to run. In practice, this means that almost any use of napi_env will be incorrect.
| 5715 | // must not run any method that would cause JavaScript to run. In practice, |
| 5716 | // this means that almost any use of napi_env will be incorrect. |
| 5717 | inline void AsyncWorker::OnExecute(Napi::Env /*DO_NOT_USE*/) { |
| 5718 | #ifdef NODE_ADDON_API_CPP_EXCEPTIONS |
| 5719 | try { |
| 5720 | Execute(); |
| 5721 | } catch (const std::exception& e) { |
| 5722 | SetError(e.what()); |
| 5723 | } |
| 5724 | #else // NODE_ADDON_API_CPP_EXCEPTIONS |
| 5725 | Execute(); |
| 5726 | #endif // NODE_ADDON_API_CPP_EXCEPTIONS |
| 5727 | } |
| 5728 | |
| 5729 | inline void AsyncWorker::OnAsyncWorkComplete(napi_env env, |
| 5730 | napi_status status, |
no test coverage detected