Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't force-exit after tests have completed #3260

Merged
merged 7 commits into from Dec 4, 2023
Merged

Conversation

novemberborn
Copy link
Member

@novemberborn novemberborn commented Nov 12, 2023

Fixes #1718.

With worker threads, this seems to stop AVA from detecting that the thread has exited, causing a hang.

Also remove flush logic implemented in #1722. Let's hope that current Node.js versions are better at flushing IPC before exiting.

  • To do: add a test Change is mainly visible in reporters which don't have great tests

Fixes #1718.

With worker threads, this seems to stop AVA from detecting that the thread has exited, causing a hang.

Also remove flush logic implemented in #1722. Let's hope that current Node.js versions are better at flushing IPC before exiting.
@novemberborn novemberborn marked this pull request as ready for review November 26, 2023 21:02
@novemberborn novemberborn merged commit af5684d into main Dec 4, 2023
13 of 14 checks passed
@novemberborn novemberborn deleted the implicit-exit branch December 4, 2023 21:22
@Raynos
Copy link

Raynos commented Dec 5, 2023

This is a non trivial breaking change. We relied heavily on the feature of ava where we didnt have to tear down any database connections etc and it would kill the process when the tests are done.

@novemberborn
Copy link
Member Author

Unfortunately it caused hard to understand errors in Node where it wouldn't exit at all.

Can you close these in an after hook? If that is problematic due to the restrictions on test declarations we could come up with another mechanism, say an event when it's safe to force the exit?

@Kikobeats
Copy link

Kikobeats commented Dec 8, 2023

I'm facing with this too – It seems to me a mechanism should be provided in order to be possible to achieve this in a explicit way (see #3259 (comment))

@Raynos
Copy link

Raynos commented Dec 14, 2023

Unfortunately it caused hard to understand errors in Node where it wouldn't exit at all.

I fully understand that is the case, this is why i've written or used other test frameworks that don't autoclose.

Going from autoclose to not autoclose is such a large breaking change you might as well switch test frameworks.

In fact it's probably cheaper and quicker for me to port the tests to node:test then figure out auto closing in the ava test suite.

@novemberborn
Copy link
Member Author

@Raynos @Kikobeats I think a import { registerCompleteHandler } from 'ava' which sets up a function to be called when AVA is done would be a decent solution. You could then registerCompleteHandler(() => process.exit()) and AVA will just assume the test worker exited on its own. This could be in a helper file that is loaded.

Other use cases are as a cleanup routine that sits outside of AVA's test & hook logic. I'm leaning to a solution like this over configuration because configuration implies we can handle edge cases in Node.js and we can't.

@novemberborn
Copy link
Member Author

#3283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wait for event loop to drain before exiting workers?
3 participants