node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Why is `ErrorReply` stack being erased?

Open GCSBOSS opened this issue 2 years ago • 4 comments

I'm trying to trace some errors in my aplication and spent a couple hours trying to figure out where this is coming from. Just to eventually trace it down to this line.

https://github.com/redis/node-redis/blob/master/packages/client/lib/errors.ts#L63

Why on earth is this being deleted?

GCSBOSS avatar Apr 25 '23 14:04 GCSBOSS

Because the stack has nothing to do with the error + the stack trace won't be that useful. Having said that, if you think it's useful we can remove this line...

@simonprickett @guyroyse WDUT?

leibale avatar Apr 25 '23 15:04 leibale

Because the stack has nothing to do with the error + the stack trace won't be that useful. Having said that, if you think it's useful we can remove this line...

@simonprickett @guyroyse WDUT?

I think you are right.

What broke in my code is that I assume Error children have a stack.

Nevertheless, I think it's useful to see the unrelated stack trace regardless. So you at least have a little direction.

GCSBOSS avatar Apr 25 '23 15:04 GCSBOSS

According to errorstack docs

The first line is formatted as <error class name>: <error message>, and is followed by a series of stack frames (each line beginning with "at ")

why not leave <error message> instead of undefined, in order not to break the code that relies on standard stack format?

konovalovsergey avatar Jun 30 '23 17:06 konovalovsergey

How do we identify which command in a function containing multiple commands actually originated the error.

In my case I am using MULTI, which makes sense that the stack trace for the individual commands ReplyErrors would not be useful. But the error I am getting doesn't actually provide a command name for what caused the error. So I assume that the error in JavaScript is actually be thrown from EXEC but this gives me so little information to try to troubleshoot the problem.

[MultiErrorReply: 1 commands failed, see .replies and .errorIndexes for more information] {
  replies: [
    1,
    true,
    [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value]
  ],
  errorIndexes: [ 2 ]
}

Did I miss somewhere in the documentation where this error structure is explained?

"see .replies and .errorIndexes for more information" is only useful if some explanation is given for what those values mean.

ajmichels avatar May 09 '24 15:05 ajmichels