-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Any way to "reset" the loop? #252
Comments
Hey @bpolaszek, thanks for bringing this up 👍 I ran into something similar a while ago in reactphp/socket#283. I would recommend to close everything at the end of your tests (Loop/connections etc.) to avoid leftovers. I also noticed that you're using an older version of reactphp/async ( I hope this helps! |
Hi @SimonFrings, Thank you for taking some time to look at this. Regarding react/async, I just upgraded to the latest commit. Now I get a different error, but that's not the point. How do you close the loop at the end of tests? By calling The only way I found to have the test suite running green is to uncomment this line. And I'm using the deprecated So, as my problem is to rely on the deprecated |
@bpolaszek I agree that this can be cumbersome sometimes, but I concur with everything @SimonFrings said: As a rule of thumb, you should never call I understand it's tempting to call You can take a look at the referenced tickets and also #237 for some additional discussion about this. I'm happy to discuss if you feel there's anything else that needs to be done on our end here. I hope this helps! 👍 |
I didn't remember participating in #237 so it looks like that same issue happened to me earlier and I ran into it again! 😅 Well, then I'll first rely on the deprecated Cheers! |
Hey there! 👋
I stumbled upon a kinda weird bug when using the loop in my CI, where some tests sometimes perform
Loop::stop()
when some others launchLoop::run()
(though they don't run concurrently). This leads to fatal errors as raised here, although they would not be raised when running tests one by one. 🤨I absolutely don't know how this is handled in the background as the fiber thing is kinda too low level to me, but it looks like the loop is sometimes left in some sort of stale state (which is not supposed to happen in production, as the loop presumably runs once). 🧐
Spawning a new loop before each test is easy to do and turns the tests to green, except it relies on deprecated code. Do you know a better way to handle this? Otherwise would it be relevant to add a
Loop::reset()
method? 💡As a side-feature-request, a
Loop::isRunning()
method would be a great help to avoid this kind of tricks (yeah, this method can be invoked from an X-Framework app as well as from a regular PHP app, meaning the loop, in this case, just has to run to execute the promise and stop immediately afterwards) because we cannot know, from the outside, whether the loop is actually running or not.Thanks! 🙏
Ben
The text was updated successfully, but these errors were encountered: