-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix: connect after client.end not working #1902
Conversation
@TimT1919 I think I covered that issue, check this PR. Also, the |
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.
Sorry @MaximoLiberata I may have explained it wrongly, there is no problem if test is written using callbacks (most of tests are using callbacks), what I wanted to do is to prevent using setTimeout, them are not reliable in tests and also make test last longer (as you have to wait the timeout to trigger.
I usually fix this by not using timeouts at all but rely on events instead (when possible) or use async/await or use sinon fake timers (you can see some tests using them)
Thanks for your help 🙏🏼
@MaximoLiberata Integrated your changes to my project and could remove my workaround for this issue. So the changes seam to resolve the issue. Thanks a lot 🙏🏼 |
You are absoluty correct, thanks. Removing setTimeout reduce time and tests won't hang up. Also, I saw if we don't close promises (async/await) that we created in the test, the test will hang up for a moment or permanent, and doesn't matter if the test it's using callback (done method), it's possible some promises didn't resolve at all. This bug happens to me when I tried throw an error with |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1902 +/- ##
==========================================
+ Coverage 80.96% 81.28% +0.31%
==========================================
Files 24 24
Lines 1408 1464 +56
Branches 331 348 +17
==========================================
+ Hits 1140 1190 +50
- Misses 185 188 +3
- Partials 83 86 +3 ☔ View full report in Codecov by Sentry. |
Fixes #1897