Giter Club home page Giter Club logo

Comments (4)

SimonFrings avatar SimonFrings commented on June 14, 2024

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 (futureTick got removed in reactphp/async#32) and reactphp/eventloop (you're using the Facotry::create() instead of Loop::get(), refs #226, #229 and #231). Maybe updating to the current versions will do the trick but I don't know for sure.

I hope this helps!

from event-loop.

bpolaszek avatar bpolaszek commented on June 14, 2024

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 Loop::close()?
So, that's what I just did, but a test is still failing when the whole test suite is ran. It doesn't fail when ran alone.

The only way I found to have the test suite running green is to uncomment this line. And I'm using the deprecated Factory::create() just because Loop::get() doesn't work, as the latter returns an (already used) singleton instead of a fresh instance.

So, as my problem is to rely on the deprecated Factory::create() method, how am I supposed to handle this?

from event-loop.

clue avatar clue commented on June 14, 2024

@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 Loop::stop() unless you're absolutely sure there's no alternative.

I understand it's tempting to call Loop::stop() in tests to interrupt the execution, but what it really means is that there are still listeners attached to the loop that will resume running the next time you call Loop::run(). As an alternative, I would highly recommend cleaning up any listeners as part of each test. Cleaning up any listeners allows the loop to stop automatically when it has nothing left to do (no timers and streams attached).

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! 👍

from event-loop.

bpolaszek avatar bpolaszek commented on June 14, 2024

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 Factory::create until its sunset, as there's no such thing as a "listener collector" (which is, from my POV, the Loop instance's job) we could invoke to clear them all.

Cheers!

from event-loop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.