-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
test_runner: ref test timeout timers #52025
Conversation
Timeouts associated with tests should keep the process alive for cases like this: ```js const { test } = require('node:test'); test({ timeout: 3000 }, (t, done) => { // done() is not called but there are no ref()'ed handles // so the process exits immediately. }); ```
Review requested:
|
@@ -0,0 +1,7 @@ | |||
'use strict'; | |||
const { test } = require('node:test'); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('very long time out ref dosent freeze process', { timeout: 30 * 1e3 }, () => {}); |
I moved this to draft status because it introduces an inconsistency where tests with a timeout keep the event loop alive, but other tests do not. We could work around this a few ways:
Thoughts? Note that options 2, 3, and 4 would also help with issues like #51952 and #52146. |
I am actually ok with the status quo. I might not understand the issue though. why would you expect the example to keep the process alive?: const { test } = require('node:test');
test({ timeout: 3000 }, (t, done) => {
// done() is not called but there are no ref()'ed handles
// so the process exits immediately.
}); I expect the timeout to be the maximum time this take should take, not the minimum. what am I missing? |
At least with mocha, if you run: it('test', (done) => {}); You get output like:
If people are fine with Node's current behavior though, I'm fine with closing this. |
Mocha has a default timeout. |
I don't think it should make a difference if a timeout is default behavior or explicitly set. I did a quick test with mocha and vitest with the following test that never finishes: it('test', () => {
return new Promise(() => {});
}); If there is a test timeout, both mocha and vitest keep the event loop alive. If you disable test timeouts, mocha exits like Node does, while vitest keeps the event loop alive. So, this PR would actually bring Node's behavior when a timeout is set in line with those two frameworks. |
Timeouts associated with tests should keep the process alive for cases like this:
Refs: #51381