Giter Site home page Giter Site logo

Comments (5)

mreiferson avatar mreiferson commented on July 25, 2024

This is unfortunate, sorry (not getting a response back from FIN) 😁

I have a suggestion though: what about tracking outstanding messages and waiting for that to hit 0 before allowing the process to exit?

I don't think it's as important to "delay" the actual FIN event vs. ensuring that you'v written/flushed the data to the socket before exiting (best effort).

from nsq.js.

tj avatar tj commented on July 25, 2024

Hmmm I wonder how we can sneak the .write callback in without being super derpy. We have the .command() callback already, so we might have to pass another one I guess haha, or only pass it on the !hasResponseCallback() check maybe

from nsq.js.

gjohnson avatar gjohnson commented on July 25, 2024

Yeah something like that @visionmedia, I'll take a look when we need to refactor other things.

@mreiferson we actually already do that. The problem is that were cheating and not providing callbacks to writes() since you can rely on error events to detect most issues. However when we write and then immediately decrement the counters, in the case of closing the process, it will think everything is safe to close because the counter is zero, but the write() may not have finished quite yet. YAY async!

Really only a problem on a super busy reader, but we have a couple of those :-)

from nsq.js.

mreiferson avatar mreiferson commented on July 25, 2024

Ah, I see, cool.

What about just force-flushing the socket (and waiting for that callback to return) before you finally exit (after the outstanding message counter has hit 0)... is that possible?

from nsq.js.

gjohnson avatar gjohnson commented on July 25, 2024

Think so, probably plays into the socket close event somewhere. Good call!

from nsq.js.

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.