NOSCRIPT No matching script. Please use EVAL.
Created by: r3wt
Description
I was experiencing an issue connecting in staging deployment to redis instance. the instance is running redis 4.0.9
on ubuntu 18.0.4
. After debugging and tweaking the config to ioredis
, i was able to overcome this. i logged the redis errors, and it spit out the following error:
error [8/28/2019, 3:00:49 AM] a redis error occurred { ReplyError: NOSCRIPT No matching script. Please use EVAL.
at parseError (/home/ciserro/staging/source/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/home/ciserro/staging/source/node_modules/redis-parser/lib/parser.js:302:14)
If this is not a problem with bull, perhaps its a problem with redis-parser, or with ioredis? i would appreciate you would inform me if that is the case so i can transfer this to a better home. but since bull is the one sending commands, it seems this belongs here (for now)
Minimal, Working Test code to reproduce the issue.
(An easy to reproduce test case will dramatically decrease the resolution time.)
the following code works, but without these options, ioredis crashes and burns spectacularly because of the invalid command (atleast the command is invalid according to the redis parser library)
const Bull = require('bull');
const Redis = require('ioredis');
const config = {
queue: {
url:'some url here',
name:'some name here'
}
};
//this is added for demo because we use a logger
function log(...args){ return console.log(...args) }
log.error = (...args)=>console.warn(...args);
function reconnectOnError(err) {
log.error('a redis error occurred',err);
return true;// if you return 2 here the first error will cause an infinite loop fwiw
}
log(config.queue.url);
const client = new Redis(config.queue.url,{reconnectOnError,connectTimeout:30000});
const subscriber = new Redis(config.queue.url,{reconnectOnError,connectTimeout:30000});
function attachListeners( c, name) {
c.on('connect',()=>log('redis(%s) connected',name));
c.on('ready',()=>log('redis(%s) is ready',name));
c.on('redis',()=>log('redis(%s) is ready',name));
c.on('error',(err)=>{
log.error('redis(%s) experienced an error',name,err);
});
c.on('reconnecting',()=>log('redis(%s) is reconnecting',name));
}
attachListeners(client,'client');
attachListeners(subscriber,'subscriber');
var options = {
createClient: function (type) {
log('create client invoked for redis(%s)',type);
switch (type) {
case 'client':
return client;
case 'subscriber':
return subscriber;
default:
return new Redis(config.queue.url);
}
}
}
const queue = new Bull(config.queue.name,options);
queue.add('my-job',{foo:true,bar:false}).then(()=>log('job added')
.catch(err=>log.error('some bullstuff happened'));
Bull version
3.10.0
Additional information
The error doesn't occur when workers are connecting, but those are running on the same server as the redis instance and connecting from local host. it is only from this remote staging machine where the problem occur.