Run some code when the process exits (supports async hooks and pm2 clustering). Latest version: 2.0.1, last published: 8 years ago. Start using async-exit-hook in your project by running `npm i async-exit-hook`. There are 340 other projects in the npm re
如果有任何AsyncHook回调抛出,应用程序会打印堆栈信息并且退出。退出路径按照未捕获异常执行,但是所有的’uncaughtException’监听器会被移除,这样强制进程退出。’exit’回调会继续执行,除非以—abort-on-uncaught-exception参数运行应用,在这种情况下会打印堆栈信息并且应用程序退出,留下一个核心文件。 这个错误处理行为的原...
如果一个 AsyncHook 回调函数中发生异常,那么服务将打印错误日志并立即退出,同时所有 ‘uncaughtException’ 监听器将被移除,同时会触发 ‘exit’ 事件。之所以会立即退出进程,是因为如果这些 AsyncHook 函数运行不稳定,下一个相同事件被触发时很可能又抛出异常,这些函数主要就是为了监听异步事件的,如果不稳定应该及时发...
资源可以在回调被调用之前关闭AsyncHook 是对这些异步资源的抽象,不关心这些异步的不同如果用了 worker,每个线程会创建独立的 async_hooks 接口,使用独立的 asyncId。为什么要追踪异步资源因为 Node.js 基于事件循环的异步非阻塞 I/O 模型,发起一次异步调用,回调在之后的循环中才被调用,此时已经无法追踪到是谁...
AsyncHook 是对这些异步资源的抽象,不关心这些异步的不同 如果用了 worker,每个线程会创建独立的 async_hooks 接口,使用独立的 asyncId。 为什么要追踪异步资源 因为Node.js 基于事件循环的异步非阻塞 I/O 模型,发起一次异步调用,回调在之后的循环中才被调用,此时已经无法追踪到是谁发起了这个异步调用。
github.com/nodejs/node/ const storageList = []; const storageHook = createHook({ init(asyncId, type, triggerAsyncId, resource) { const currentResource = executionAsyncResource(); // Value of currentResource is always a non null object for (let i = 0; i < storageList.length; ++i) {...
but on the main thread rather than a Worker thread. test: regression tests for async_hooks + Promise + Worker interaction Add regression tests for the case in which an async_hook is enabled inside a Worker thread andprocess.exit()is called during the ...
If any AsyncHook callbacks throw, the application will print the stack trace and exit. The exit path does follow that of an uncaught exception, but all 'uncaughtException' listeners are removed, thus forcing the process to exit. The 'exit' callbacks will still be called unless the application...
而在async call after时,则是调用出栈方法 namespace.exit(storage)。 这个过程中,传入的参数 storage,就是我们在 store 中存入的 traceId // cls的实现 // 这是 store 全局变量的 class function Namespace(name) { this.name = name; // changed in 2.7: no default context this.active = null; this...
async-cache async-csv async-eventemitter async-exit-hook async-iterable-stream async-lock async-polling async-redis async-rerun async-retry async-stream-emitter async-stream-generator async-writer async.nexttick async at-least-node athenajs atlaskit__layer atlaskit__single-select ...