process beforeExit event not called
🐛 Bug Report
beforeExit event is never called.
We are using this event to release resources of a Rust library upon object's garbage collection, using https://github.com/node-ffi-napi/weak-napi.
To Reproduce
process.on('beforeExit', () => {
console.log('beforeExit')
})
describe('mytest', () => {
it('should do stuff', () => {
console.log('hey')
})
})
Expected behavior
We should see beforeExit logged.
The same test works fine with Mocha, where beforeExit is successfully called.
envinfo
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 12.19.1 - ~/.nvm/versions/node/v12.19.1/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.19.1/bin/npm
Just hit this. Any thoughts? It seems not so great that this doesn't work.
As part of my other bug report I went ahead and added a reproduction for this bug as well since they might be related? https://github.com/cowboyd/jest-suite-hooks-on-sigint
@OoDeLally It should also be noted that the same holds true for the exit event.
Any thoughts on how we can contribute to the resolution of this?
Are there any work arounds?
@eladchen I have not been able to find any 😢
This is still the case in 27.5.1, it really shouldn't be.
Strong agree. Hopefully with Facebook setting this project free this will get some attention.
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.
👍🏻
Just faced this with pino transport which runs in a worker thread and listens to the 'beforeExit' event:
Jest has detected the following 1 open handle potentially keeping Jest from exiting
I just ran into this. We use this handler to ensure that certain child processes spawned by a service is killed when the program exits, but it doesn't work under jest.
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.
Not stale
Jest is stale, I switched to node --test and it can also run TypeScript files.
how to fix pino memory leak with jest ?
Disappointing that this has been open for 5 years and nobody from the Jest team has responded to it 🫤