Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

why close does not exit? #26

Closed
guotie opened this issue May 8, 2014 · 5 comments
Closed

why close does not exit? #26

guotie opened this issue May 8, 2014 · 5 comments

Comments

@guotie
Copy link

guotie commented May 8, 2014

var nsq = require('nsq.js');

var writer = nsq.writer('10.10.133.80:4150');
writer.publish('urlitems', "www.sina.com.cn");
console.log("ok.");
writer.close();

when i run it, the command do not exit, why?

@juliangruber
Copy link
Contributor

i can reproduce, investigating

@juliangruber
Copy link
Contributor

nsq.js doesn't queue ops when the connection isn't ready yet, thus listen to the ready event:

var nsq = require('nsq.js');

var writer = nsq.writer('10.10.133.80:4150');
writer.once('ready', function(){
  writer.publish('urlitems', "www.sina.com.cn");
  console.log("ok.");
  writer.close();
});

@guotie
Copy link
Author

guotie commented May 8, 2014

thanks.

document it in the readme is better.

@juliangruber
Copy link
Contributor

@visionmedia what's your plan for this?

@tj
Copy link
Contributor

tj commented May 8, 2014

probably just leave it as-is for now (with docs), maybe buffer some day but if a connection goes down and we buffer our latency could be pretty awful, almost better to just respond with an error until things are fine, or we could have a bunch of timeouts etc but that would probably be over-engineering for now

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants