Giter Club home page Giter Club logo

Comments (3)

sli avatar sli commented on July 20, 2024

I've figured out that I'm not getting ECONNREFUSED from the connection attempt, so that is clearly the issue. Not really a problem when things go to production and the backend is long-running, but in development that's going to be a hassle.

I suppose I could just manually trigger a reconnect to workaround this for the moment. E: Nevermind, it doesn't attempt to reconnect even when triggering it manually, as it still thinks it's hit the maximum number of attempts already.

E2: After further tinkering (read: editing dependencies manually) and manually attempting a reconnect, it seems that the current number of attempts is undefined inside the library's own onreconnect handler, then becomes NaN. Left is num, right is maxAttempts:

image

This makes sense, as the connection is never opened, so onopen is not called, and so num is never initialized to 0. Can confirm that initializing num to 0 allows for this workflow.

from sockette.

lukeed avatar lukeed commented on July 20, 2024

IMO, this makes sense, unless I'm missing something here?

You can only re-connect after having connected in the first place.

Initializing num=0 at the start would fix this for you, but I feel like it's encouraging lack of error handling. You should definitely be handling ECONNREFUSED & the like manually, or kill the process. That's what the hooks are intended for, really.

It'd be much worse to (potentially) indefinitely ping your server that's shut down or choking.

What do you think?

from sockette.

lukeed avatar lukeed commented on July 20, 2024

Hey @sli – it looks like you edited your response after I replied, so I never saw that last portion (and was never notified)

Are you saying that the fix was to declare num=0 at the top of the constructor?

from sockette.

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.