| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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:
|
Sorry, something went wrong.
Sorry, something went wrong.
| @@ -0,0 +1,7 @@ | |||
| 'use strict'; | |||
| const { test } = require('node:test'); | |||
|
|
|||
There was a problem hiding this comment.
| test('very long time out ref dosent freeze process', { timeout: 30 * 1e3 }, () => {}); |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
At least with mocha, if you run: it('test', (done) => {});You get output like: 1) test
0 passing (2s)
1 failing
1) test:
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/private/tmp/test.js)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
If people are fine with Node's current behavior though, I'm fine with closing this. |
Sorry, something went wrong.
|
Mocha has a default timeout. node:test doesn't really have one |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Timeouts associated with tests should keep the process alive for cases like this:
Refs: #51381