nsqjs icon indicating copy to clipboard operation
nsqjs copied to clipboard

Connection error event never fired if Reader initialised with `lookupdHTTPAddresses`

Open yangit opened this issue 5 years ago • 3 comments

Hi, If I initialise Reader with lookupdHTTPAddresses variable set to garbage

const reader = new nsq.Reader('test', 'test2', {
    lookupdHTTPAddresses: 'garbage:9999', 
});

const handler = () => {
    console.log('!!!handler fired!!');
    process.exit();
};
reader.on('error', handler);
reader.on('message', handler);
reader.on('discard', handler);
reader.on('nsqd_connected', handler);
reader.on('nsqd_closed', handler);

reader.connect();

The error event is never dispatched.

If I initialise with nsqdTCPAddresses it works as expected. Is it a bug?

yangit avatar Sep 09 '20 06:09 yangit

I found the culprit: https://github.com/dudleycarr/nsqjs/blob/master/lib/lookupd.js#L39

I'll get a fix in for that over the weekend.

dudleycarr avatar Sep 10 '20 21:09 dudleycarr

Please check this line as well https://github.com/dudleycarr/nsqjs/blob/master/lib/lookupd.js#L53 It seems to not pass the error down.

yangit avatar Sep 11 '20 02:09 yangit

Bump - I've just hit this bug too.

smfreegard avatar Sep 13 '23 11:09 smfreegard