MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / OnExecute

Method OnExecute

napi-inl.h:5717–5727  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
5717inline 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
5729inline void AsyncWorker::OnAsyncWorkComplete(napi_env env,
5730 napi_status status,

Callers 1

OnAsyncWorkExecuteMethod · 0.95

Calls 1

whatMethod · 0.80

Tested by

no test coverage detected