-
Notifications
You must be signed in to change notification settings - Fork 32
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
Improve error handling #100
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this would work well as it would make call next
twice/after boot is completed if the there is an error in the connection later on.
I think you need to remove the |
My bad, i thought it was possible to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please not return
the client?
index.js
Outdated
} else { | ||
next() | ||
const onError = function (err) { | ||
client.quit(() => next(err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should quit the client on the first error. In this case we are avoiding the retry strategy that is really important imho.
If we want to go with this event
path I think we need to manually handle the retry strategy.
} | ||
|
||
next() |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When specified lazyConnect
, the if clause will stop at return client
and next
is not reachable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
index.js
Outdated
// Any other errors during startup will | ||
// trigger the 'end' event. | ||
if (err instanceof Redis.ReplyError) { | ||
this.emit('end', err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we did not call emit()
on an object we do not maintain. Just call the onEnd()
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Checklist
npm run test
andnpm run benchmark
and the Code of conduct
Description
Closes #95
This PR improves error handling, it will make the plugin wait until
Redis
instance firesready
event before calling thenext
function, it will also listen to theerror
event and propagate errors in case anything goes wrong on initial startup.