-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
Iterating over Readable streams never resolves with fake timers #2619
Comments
I am guessing this is related to us now faking all timers by default in version 13 of Fake Timers, which is a breaking change (hence the new major version of Sinon): https://github.com/sinonjs/fake-timers/blob/main/CHANGELOG.md#1300--2024-08-25 Somehow the underlying code you are using might depend on |
Great testcase. Made it very easy to reproduce and look into. Was exactly what I assumed. This fixes/avoids your issue:
EDIT: while it avoids the issue, I find it much better to keep this as an async function and I suggest an alternative below. |
@SimenB This might be a side-effect you can be aware of in Jest. Not sure how we should document this. |
Just to add some info. It's the I pushed a "fix" to your example: fatso83/usefaketimers-bug-reproduction@54c812d Hope that helps! |
I'll add this as a note to the migration guide: https://sinonjs.org/guides/migration-guide. Thanks! |
Describe the bug
With sinon v19 and using fake timers
Readable
streams will never resolve. This causes tests that need to evaluate the contents ofReadable
streams to timeout. Now it might be I shouldn't expect this to work as I am doing async stuff, but this did work with sinon v18 so for now I'd at least consider this a bug.To Reproduce
Steps to reproduce the behavior:
sinon.useFakeTimers
or similarI've created a reproduction repo of this https://github.com/mattdean-digicatapult/usefaketimers-bug-reproduction if you'd like to test it out. The test code is as follows:
Expected behavior
The stream to finish reading as occurred in sinon v18
Screenshots
Context (please complete the following information):
Sinon version : v19.0.0
Runtime: nodejs 22
Other relevant environmental info: macos
Other libraries you are using: Mocha, Chai (see reproduction for versions)
Example URL: https://github.com/mattdean-digicatapult/usefaketimers-bug-reproduction
Additional context
None
The text was updated successfully, but these errors were encountered: