turborepo
7518fbad - Add new ExitHandler API as an alternative to ExitGuard (#8547)

Commit
1 year ago
Add new ExitHandler API as an alternative to ExitGuard (#8547) ## Why? I need a better system for handling process exit to handle flushing to cache hit statistics (#8286). ## What? - Supports letting another thing listen for <kbd>ctrl</kbd> + <kbd>c</kbd>. In the case of next-server, we need to let node.js own and configure these signal handlers. - Supports setting up a <kbd>ctrl</kbd> + <kbd>c</kbd> handler for you, but now explicitly panics if you would try to set up multiple global <kbd>ctrl</kbd> + <kbd>c</kbd> listeners. - Allows async work to happen during cleanup. This wasn't possible using `Drop` because `Drop` isn't async. - Allows cleanup work to be scheduled after application initialization, potentially making the API a bit more flexible. ## Testing Instructions ``` cargo test -p turbopack-trace-utils ``` Add some `println!()` logging to the end of the `on_exit` future in turbopack-cli. ``` TURBOPACK_TRACING=overview cargo run -p turbopack-cli -- dev ``` Hit `ctrl+c` and see that my `println!()` runs, so I know the tracing flush finishes.
Author
bgw bgw
Parents
Loading