Redis connection error event handler is set ONLY after connection is established
See original GitHub issueBull Version: 1.40.1
const queue = new Queue('test', {
connection: {
host: 'localhost',
port: 6379,
},
});
queue.on('error', () => console.log('Something went wrong!'));
An unhandled error event is logged by IORedis when creating a new queue with no redis server available.
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1142:16)
If there is a redis server available during the queue creation and somehow lost connection to the redis server, the queue will emit an error with Something went wrong!.
After some investigation, I found out that the error event hook is set after a initializing has been resolved. However, in the case where there is no redis server available during queue creation, it will be stuck in waitUntilReady promise and thus not setting the error event hook.
I will suggest to place the hook at here instead of after the initializing has been resolved. What you do think?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Redis (ioredis) - Unable to catch connection error in order to ...
I've set lazyConnect to true in order to handle errors on the caller. But, when I define the url as localhoste:6379 (instead of...
Read more >RedisConnectionException: No connection is available to ...
Connecting to it fails immediately despite the timeouts I've set. When I tried using an invalid host name and/or invalid port the timeouts...
Read more >Error detection and handling with Redis - IBM Developer
When I initialize the ioredis library, a network connection is made, authentication credentials are exchanged, certificates are checked, and the ...
Read more >Redis client handling
When Redis can't accept a new client connection because the maximum number of clients has been reached, it tries to send an error...
Read more >The Proper Way To Connect Redis — Node.js | by Eren Yatkin
When we get an end event, timeout will start, then Redis will try to reconnect. We will wait until the timeout. setTimeout() will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

That is quite strange considering there are 231 tests in total…
Alright! I will create a PR to address this.