当前 Node.js 环境退出时的清理


【Cleanup on exit of the current Node.js environment】

虽然 Node.js 进程在退出时通常会释放其所有资源,但 Node.js 的嵌入者或将来的 Worker 支持可能要求插件注册清理钩子,这些钩子将在当前 Node.js 环境退出时运行。

【While a Node.js process typically releases all its resources when exiting, embedders of Node.js, or future Worker support, may require addons to register clean-up hooks that will be run once the current Node.js environment exits.】

Node-API 提供了用于注册和注销此类回调的函数。当这些回调被执行时,所有由插件持有的资源都应被释放。

【Node-API provides functions for registering and un-registering such callbacks. When those callbacks are run, all resources that are being held by the addon should be freed up.】