-   Notifications  
You must be signed in to change notification settings  - Fork 1.4k
 
Do not count writes to stdout/stderr as non-idling activity for timeouts #3374
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
   Merged  
     Merged  
 Changes from all commits
 Commits 
  Show all changes 
  8 commits   Select commit Hold shift + click to select a range 
 27c6236  Fix timeouts so that stdout/stderr activity does not keep a test running 
  mdouglass 8e8005b  make xo happy 
  mdouglass 0b81b8d  move test to idle-timeouts directory 
  mdouglass b6191c6  revert test-timeouts snapshot 
  mdouglass c13ef4b  amend comment 
  mdouglass 084742d  Merge branch 'main' into fix/3373 
  novemberborn 72fd4e8  Reword debounce comment 
  novemberborn 03cd818  Clean up test 
  novemberborn File filter
Filter by extension
Conversations
 Failed to load comments.  
    Loading  
 Jump to
  Jump to file  
  Failed to load files.  
    Loading  
 Diff view
Diff view
There are no files selected for viewing
   This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
        This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import {setTimeout as delay} from 'node:timers/promises'; | ||
| import test from 'ava'; | ||
|   |  ||
| test('timeout with console output', async t => { | ||
| t.timeout(1000, 'timeout despite console output'); | ||
| for (let i = 0; await delay(100, true); i++) { | ||
| if (i % 2 === 0) { | ||
| console.log('stdout'); | ||
| } else { | ||
| console.error('stderr'); | ||
| } | ||
| } | ||
| }); | 
   This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "type": "module", | ||
| "ava": { | ||
| "files": [ | ||
| "*.js" | ||
| ], | ||
| "timeout": "500ms" | ||
| } | ||
| } | 
   This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters   
     | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import test from '@ava/test'; | ||
|   |  ||
| import {fixture} from '../helpers/exec.js'; | ||
|   |  ||
| test('idle timeouts are not blocked by console output', async t => { | ||
| const result = await t.throwsAsync(fixture(['console-output.js'])); | ||
| const error = result.stats.getError(result.stats.failed[0]); | ||
| t.is(error.message, 'timeout despite console output'); | ||
| }); | 
 Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.    
 
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.
I'd personally prefer to make this opt-in so only assertions/test state changes reset the timeout (so we hew closer to the documentation).
But:
a) I don't know the complete list of record type's here that would apply
b) it's a bigger change from current behavior than I'm comfortable making without feedback
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.
I think this change is correct. The timeout here is a guard against test workers that are no longer making progress. It's different from
t.timeout()which limits how long an individual test can take.Essentially with this change, we no longer count stdout/stderr as "making progress".