-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: connect ETIMEDOUT ----use bluebird #977
Error: connect ETIMEDOUT ----use bluebird #977
Comments
Seeing the same issue as well. It only impacts the initial startup connection. Easiest workaround I've found is to set a low connectTimeout value. The subsequent retry works as expected. On a handful of occasions it has started properly the first time perhaps suggesting a race condition? |
The same happened to me on cluster mode with the following code:
And here is the debug log:
|
+1 |
+10086 |
check the file in node_modules /ioredis/built/connectors/StandaloneConnector.js var Promise = PromiseContainer.get(); before return new Promise(); |
i use the code OP posted above and don't have any problem.
|
Just to echo what @Noly1990 said - looks like an issue with the assumption that The root cause here is over my head, but a quick patch along these lines this would be an enormous help to our team:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed. |
Still actual: #1074 |
Experiencing this too :/ |
Bluebird is somehow too fast. It's changing the ordering of the event loop such that the connect event is firing before the connect handler gets a chance attach to it. Here's a repro that demonstrates the problem:
I think the reason localhost works is because it's being resolved, which adds enough delay to subvert bluebird's speed.
We probably shouldn't be waiting for the We should reopen this one @luin and can probably close #1074 as a dupe. |
I come to think of there's a todo for this issue: https://github.com/luin/ioredis/blob/758b3f29036c7830e963ac3d34d3ce9cc7c4cb52/lib/connectors/StandaloneConnector.ts#L54-L60 Currently the recommended way to plug custom Promise implementation would be using |
Hmm I see. This probably wasn't an issue before this change, when connections were converted from callbacks to promises: https://github.com/luin/ioredis/pull/906/files#diff-05873f3a84814480fe7e81d9cb56acf4R20 Is it simpler to just revert to callbacks? 🙃 it would be breaking @imatlopez 's custom connector contract... |
Confirmed with a quick test that reverting to callbacks would resolve this issue, but with the caveat mentioned above. As an alternative option, I naively tried following the comment advice
But it doesn't resolve the issue. For this alternative approach to work we'd probably have to move that What do you think @luin ? |
you can tell whether a function wants a callback by the length of that function, no need to break the promise contract now |
@alavers I'd think we can check if if (isConnected(stream)) {
process.nextTick(eventHandler.connectHandler(_this))
} else {
stream.once(CONNECT_EVENT, eventHandler.connectHandler(_this));
} Not sure if Node.js provides enough APIs for the |
It's possible for connect promise to resolve after the resolved connection has already been established, which means we miss the connect event. This can happen when Bluebird is set as the global Promise, and we connect to an ip address host for example. This fix checks to see if that's the case and invokes the connection handler directly. Thanks @luin for the recommendation. Fixes redis#977
Seeing the same issue here as well. |
It's possible for connect promise to resolve after the resolved connection has already been established, which means we miss the connect event. This can happen when Bluebird is set as the global Promise, and we connect to an ip address host for example. This fix checks to see if that's the case and invokes the connection handler directly. Thanks @luin for the recommendation. Fixes #977
🎉 This issue has been resolved in version 4.16.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
nice ! |
Let's see if we can fix the issue with the bluebird global promise and the stream trying to connect too fast and missing the exception. redis/ioredis#977
## [4.16.2](redis/ioredis@v4.16.1...v4.16.2) (2020-04-11) ### Bug Fixes * dismiss security alerts for dev dependencies [skip release] ([758b3f2](redis/ioredis@758b3f2)) * handle connection after connect event was emitted ([#1095](redis/ioredis#1095)) ([16a0610](redis/ioredis@16a0610)), closes [#977](redis/ioredis#977)
I use bluebird replace native promise, error happened!
envriment:
my test code
The text was updated successfully, but these errors were encountered: