@@ -493,8 +493,12 @@ implementation can use to persist VM-specific state. This structure is passed
493493to native functions when they're invoked, and it must be passed back when
494494making N-API calls. Specifically, the same `napi_env` that was passed in when
495495the initial native function was called must be passed to any subsequent
496- nested N-API calls. Caching the `napi_env` for the purpose of general reuse is
497- not allowed.
496+ nested N-API calls. Caching the `napi_env` for the purpose of general reuse,
497+ and passing the `napi_env` between instances of the same addon running on
498+ different [`Worker`][] threads is not allowed. The `napi_env` becomes invalid
499+ when an instance of a native addon is unloaded. Notification of this event is
500+ delivered through the callbacks given to [`napi_add_env_cleanup_hook`][] and
501+ [`napi_set_instance_data`][].
498502
499503### napi_value
500504
@@ -5304,8 +5308,10 @@ This API may only be called from the main thread.
53045308[Xcode]: https://developer.apple.com/xcode/
53055309[`Number.MAX_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.max_safe_integer
53065310[`Number.MIN_SAFE_INTEGER`]: https://tc39.github.io/ecma262/#sec-number.min_safe_integer
5311+ [`Worker`]: worker_threads.html#worker_threads_class_worker
53075312[`global`]: globals.html#globals_global
53085313[`init` hooks]: async_hooks.html#async_hooks_init_asyncid_type_triggerasyncid_resource
5314+ [`napi_add_env_cleanup_hook`]: #n_api_napi_add_env_cleanup_hook
53095315[`napi_add_finalizer`]: #n_api_napi_add_finalizer
53105316[`napi_async_init`]: #n_api_napi_async_init
53115317[`napi_cancel_async_work`]: #n_api_napi_cancel_async_work
@@ -5341,6 +5347,7 @@ This API may only be called from the main thread.
53415347[`napi_queue_async_work`]: #n_api_napi_queue_async_work
53425348[`napi_reference_ref`]: #n_api_napi_reference_ref
53435349[`napi_reference_unref`]: #n_api_napi_reference_unref
5350+ [`napi_set_instance_data`]: #n_api_napi_set_instance_data
53445351[`napi_set_property`]: #n_api_napi_set_property
53455352[`napi_throw_error`]: #n_api_napi_throw_error
53465353[`napi_throw_range_error`]: #n_api_napi_throw_range_error
0 commit comments