-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove try_callback #816
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
Remove try_callback #816
Conversation
@brycebaril and/or @mranney, could you give some context regarding the |
Reference #543 |
The original commit for this is 202df58 and it had nothing to do with domains. As I see it the only thing with domains was, that they had to be added added in the try_callback as node-redis catched those errors too. By removing this nothing should be broken at all. |
The original commit is faulty and this should have never been introduced. It tries to fix wrong user code by throwing the user error async instead of sync. So this is a bug fix overall without any negative impact on domains. |
Judging by the original PR, the reason this exists is for multiplexed replies such as:
Rethrowing on the next stack allows the parser to continue and handle the |
But those do not happen in the user callback? |
@BridgeAR they happen when there is an error in a multiplexed reply, which are particularly the rethrow on https://github.com/NodeRedis/node_redis/blob/master/index.js#L539-L547 is designed to protect this |
I think that, worst case, this will require people who want calls into redis to play nice with domains will need to go back to I'm +0 on this change – I think the way that this code deals with errors is sufficiently opaque that relatively few users of the library understand how to handle errors with it correctly, and this change is likely to leave people in a confused state in at least a few cases, but the patch also removes some complexity. |
@othiym23 the binding is still in place and working. Your original test is passing just fine. @brycebaril I wrote different multiplexed examples now and they are all handled properly and just the same as with the try catch. There was an error that the js parser replied errors as strings that I already fixed. Overall I'm very certain that this code was a bug not a feature ;) |
@@ -739,9 +704,16 @@ RedisClient.prototype.send_command = function (command, args, callback) { | |||
|
|||
// if the value is undefined or null and command is set or setx, need not to send message to redis | |||
if (command === 'set' || command === 'setex') { | |||
if(args[args.length - 1] === undefined || args[args.length - 1] === null) { | |||
if (args.length === 0) { |
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'm uncertain if we want to support this behavior but this is how the tests behave right now. I'd say it's very unlikely that any user is going to call set
/ setex
without any arguments. They might be undefined, but that would result in an error... I'd say let's not support this?
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.
Ping @bcoe @brycebaril
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.
Since there are still some open issues about undefined
and null
values passed into redis we're going to have to have a closer look at this later on anyway. Therefor I'll merge it as is.
This is going to fix three things:
As a nice side effect this should not only make the code base clearer but also speed up some calls as the try catch is not optimized well in v8. This is not breaking the domains as I already tried to outline. That is still in place and working as it should. This might break users code that tried to work around these issues but they should still be fixed in my opinion. So this should go into the next major version. |
I edited the comment above and removed the error wrapping into another PR |
@BridgeAR I like that this simplifies the error handling logic, moving towards always emitting, and that it gets rid of some opaque code. I say that we release this as part of |
Thrown errors might kill the users app. By emitting the errors the user is able to catch all errors in one place without the app going down
I can't see that this would harm anyone