-
Notifications
You must be signed in to change notification settings - Fork 6.3k
refactor: add timeout for race condition in heart test #5131
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
Conversation
✨ code-server docs for PR #5131 is ready! It will be updated on every commit.
- Host: https://coder.com/docs/code-server/5cbc558
- Last deploy status: success
- Commit: 4ad1d02
- Workflow status: https://github.com/coder/code-server/actions/runs/2228259663
Codecov Report
Merging #5131 (4ad1d02) into main (18ff996) will not change coverage.
The diff coverage isn/a
.
@@ Coverage Diff @@ ## main #5131 +/- ## ======================================= Coverage 71.73% 71.73% ======================================= Files 30 30 Lines 1684 1684 Branches 374 374 ======================================= Hits 1208 1208 Misses 407 407 Partials 69 69
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 18ff996...4ad1d02. Read the comment docs.
test/unit/node/heart.test.ts
Outdated
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.
It occurs to me that if we allow it to be equal then technically we are not testing anything because this will pass if the file is not modified. Any idea if this still flakes if we remove the equal?
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.
Maybe what we can do is set the modified time explicitly before the heartbeat (to something like 0 to simulate the file being really old) and then do the comparison?
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.
Oh good point. Let me remove the Equal and check. I also like the idea of explicitly setting. That gives us more control.
test/unit/node/heart.test.ts
Outdated
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.
Whoops, sorry I linked you to the wrong section that makes you open a file handle. I think you might have to close this as well? But it might be easier to use this one: https://nodejs.org/api/fs.html#fspromisesutimespath-atime-mtime
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.
Oh, no, that's my bad. I assumed you could only access utimes
after opening the file and didn't bother checking the rest of the docs. Yeah, that would leak since I don't have logic to close it (I've run into that with Deno).
Nice!!! Our codebase thanks you for your attention-to-detail 😂
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.
Awesome! This seems like it should be solid.
test/unit/node/heart.test.ts
Outdated
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.
Looks like we can remove open
now.
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.
Oh whoops! VS Code should remove those for you 😛 Removing then merging
@code-asher was right. #5122 introduced a flakey test due to async logic in
beat
. Added an artificial timeout in test to ensure no race conditions and test always passes.Had to re-run Build job here: https://github.com/coder/code-server/actions/runs/2228063603
Fixes N/A