question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

process beforeExit event not called

See original GitHub issue

🐛 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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

1reaction
cowboydcommented, Jan 21, 2022

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

0reactions
cowboydcommented, Jun 8, 2022

Strong agree. Hopefully with Facebook setting this project free this will get some attention.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SIGINT, beforeExit and exit event handlers not called for ctrl-c ...
I'm asking because the order each process in the pipeline receives SIGINT is uncertain. I suspect the issue here is that tee dies...
Read more >
Process | Node.js v19.3.0 Documentation
The 'beforeExit' event is not emitted for conditions causing explicit termination, such as calling process.exit() or uncaught exceptions. The 'beforeExit' ...
Read more >
Node.js – Process beforeExit Event - Tutorialspoint
Node.js – Process beforeExit Event - The 'beforeExit' event is called when Node.js empties its event loop and has no other work to...
Read more >
process
The 'beforeExit' event is not emitted for conditions causing explicit termination, such as calling process.exit() or uncaught exceptions. The ' ...
Read more >
Node.js Process beforeExit Event - GeeksforGeeks
Parameters: This event does not accept any argument as the parameter. Return Value: This event returns nothing but a callback function for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found