-
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
Using Scan: Cannot read property '0' of undefined #199
Comments
I think the problem is ioredis doesn't handle the error. this.opt.redis[this.opt.command](args, function (_, res) {
console.log('ScanStream receives an error', _); |
Yeah I will certainly do that. I will let you know next Monday if I run into any errors with this, and what those errors are. We run the workers over the weekend so I won't know before then. |
Okay so here is the error that I am getting. I received this error 2 times out of all the jobs we ran +2k. Again the retry on the jobs worked just fine.
Note: I do have offline queue set to false as I don't want to queue any data up (our worker has a hard ram limit and its small so I can't afford to buffer/queue very many items, or it will force kill the worker immediately). |
This error will be emitted when the connection is down and |
Yeah sounds good. Just let me know when you have this error getting forwarded to the error handler so I can catch it and then do as you suggested 😄 |
Released in 1.12.1 😆 var stream = redis.scanstream({ count: 1 });
stream.on('data', function (data) {
});
stream.on('error', function (err) {
}); |
Thanks! |
We run a bunch of worker processes that use redis to store some temporary state and we use scan streams to pull out any remaining redis records that might still remain in redis and process those before terminating the worker. We run this worker about 1-2k times a week and I have noticed that a couple of our workers are failing with this error being thrown by bluebird and leading back into ioredis scan streaming code. Here is the full error:
The piece of ioredis code that it is pointing to is here:
The error is occurring because I believe
res
is either undefined or is not an array so it can't be accessed by using[0]
. I believe this is probably some sort of race condition maybe or something weird like that because it only happens occasionally (3 out of 1-2k) and when the system auto retries those workers after a failure it always succeeds (so not easily reproducible).My thought is maybe we should be checking to see if
res
exists first before doing the[0]
index, but I didn't write this lib so mayberes
should never be null and this should be handled elsewhere outside the code.Any help or clarity on this issue would be much appreciated.
The text was updated successfully, but these errors were encountered: