upstash / issues

Issue Tracker for Upstash
https://upstash.com
2 stars 0 forks source link

Error running script for bullmq #16

Open zlace0x opened 2 years ago

zlace0x commented 2 years ago

Encountered this error running bullmq with upstash, the same example works fine on local redis. Also the older bull example works fine with upstash.

ReplyError: ERR Error running script: @globals:16: Script attempted to access nonexistent global variable 'cmsgpack' stack traceback:  [G]: in function 'error'  @globals:16: in function <@globals:14>  @user_script:42: in main chunk  [G]: ?
    at parseError (/home/alphanoder/dev/observer/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/home/alphanoder/dev/observer/node_modules/redis-parser/lib/parser.js:302:14) {
  command: {
    name: 'evalsha',
    args: [
      '9c1536ab60864b760e3df0fe198ee7d7973371d3',
      '9',
      'bull:hello.queue:wait',
      'bull:hello.queue:paused',
      'bull:hello.queue:meta',
      'bull:hello.queue:id',
      'bull:hello.queue:delayed',
      'bull:hello.queue:priority',
      'bull:hello.queue:completed',
      'bull:hello.queue:events',
      'bull:hello.queue:delay',
      <Buffer 97 b1 62 75 6c 6c 3a 68 65 6c 6c 6f 2e 71 75 65 75 65 3a a0 a9 6d 79 4a 6f 62 4e 61 6d 65 cb 42 77 d9 8d ce 31 50 00 c0 c0 c0>,
      '{"foo":"bar"}',
      <Buffer de 00 04 a8 61 74 74 65 6d 70 74 73 00 a5 64 65 6c 61 79 00 a5 6a 6f 62 49 64 c0 a7 62 61 63 6b 6f 66 66 c0>
    ]
  }
}

Code

// load environment variables
import * as dotenv from "dotenv";
dotenv.config();
import Redis from "ioredis";
import { Queue } from "bullmq";

const connection = new Redis(process.env.REDIS_CONNECTION, {
  enableReadyCheck: false,
  maxRetriesPerRequest: null,
});

const myQueue = new Queue("hello.queue", { connection });

async function addJobs() {
  try {
    await myQueue.add("myJobName", { foo: "bar" });
  } catch (err) {
    console.log(err);
  }
}

addJobs();
mdogan commented 2 years ago

Thanks for the report @zlace0x.

It seems bullmq started to use cmsgpack encoding. Older bull was not using it. See old addJob Lua: https://github.com/OptimalBits/bull/blob/develop/lib/commands/addJob-6.lua vs New `addJob: https://github.com/taskforcesh/bullmq/blob/master/src/commands/addJob-9.lua

Currently Upstash does not support cmsgpack in Lua scripts, unlike original Redis. For the time being you can use the older bull implementation.

uncvrd commented 2 years ago

@zlace0x what version of bullmq did you have to revert back to? I tried dropping back to v1.49 which was the last version before the issue @mdogan referenced was merged but now I'm getting a:

ERR Command is not available: 'XREAD'

🤔

zlace0x commented 2 years ago

@uncvrd I'm using the older bull implementation instead of bullmq.

uncvrd commented 2 years ago

@zlace0x OH gotcha thank you! I'm not a redis expert but I guess XREAD is from Streams which is not supported yet on Upstash, bummer.

image