7761922b创建于 2025年9月26日历史提交

Node-API FAQs

Stability

  1. How do I troubleshoot the issue that an application often crashes during running?
  2. How to handle thread safety issues when the ArkTS method is concurrently called in the thread pool?
  3. What should I do if the content of napi_value changes?
  4. Is there a method to obtain the latest napi_env?
  5. What should I do if napi_add_env_cleanup_hook is called incorrectly?

Memory Leak

  1. Is there any mechanism to check whether napi_ref leaks?
  2. How do I locate and resolve memory leaks during Node-API development?
  3. For details about parameter leaks, see napi_open_handle_scope and napi_close_handle_scope.
  4. What should I do if memory leaks when napi_threadsafe_function is used?

Basic Functionalities

  1. What should I do if the module fails to be loaded and the error message "Error message: is not callable" is displayed?
  2. How to ensure the order of asynchronous tasks in scenarios where a large number of ArkTS methods need to be called for communication?
  3. Is there a convenient way to call back ArkTS?
  4. How do I invoke a function transferred from ArkTS in a C++ subthread?
  5. How to ensure the correct mapping of data types and the security of memory management?
  6. Integrating a Third-Party Dynamic Link Library
  7. What are the error codes of the napi_get_uv_event_loop API?
  8. Must a function be passed to the native layer when the native layer calls the object method of the ArkTS layer?
  9. Can I call an ArkTS method and obtain the result?
  10. Whether there is a napi_get_value_string_utf8 API or capability that does not need the copy operation?
  11. What are the precautions for using napi_env in multi-thread mode?
  12. What should I do if the napi_call_threadsafe_function execution sequence does not meet the expectation?
  13. What should I do if an error message "undefined" is displayed on the ArkTS side?
  14. What should I do if the API execution result is unexpected?
  15. What are the differences between the lifecycle of napi_value and napi_ref?
  16. How do I locate the fault if the return value of a Node-API is not "napi_ok"?
  17. How do I ensure that objects wrapped by napi_wrap are destructed in the expected order?
  18. What should I do if the napi_call_threadsafe_function callback task is not executed?