taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
5.93k stars 384 forks source link

ERR user_script:36: bad argument #1 to 'unpack' (string expected, got nil) with empty Redis cache #2638

Open gaurangparmar89 opened 2 months ago

gaurangparmar89 commented 2 months ago

I'm encountering an error when trying to initialize a BullMQ worker with an empty Redis cache. The error occurs even when there's no data in Redis, which seems unexpected.

Error message: ReplyError: ERR user_script:36: bad argument #1 to 'unpack' (string expected, got nil) script: 762279fdd5e160218e47de08664b7b833401cc03, on @user_script:36.

Environment:

I was trying to implement rate limiting earlier and might have had a few stalled jobs due to the same but have cleared all redis data post that.

manast commented 2 months ago

If you provide a small test case that reproduces the issue we can easily tell you what is wrong with it, seems like you are passing an invalid argument somewhere.

maxdeichmann commented 3 weeks ago

@manast i had the same issue when having two different bullmq versions installed in the same project. Maybe this helps you.

manast commented 3 weeks ago

@maxdeichmann unfortunately not. Code that reproduces the issue is what we would need in order to investigate the issue.

roggervalf commented 3 weeks ago

@maxdeichmann but why you are using different versions. It should be better to use the same

maxdeichmann commented 3 weeks ago

I did not do that on purpose. I am using a monorepo where one package in the repo had another bull version as another one. As soon as both had the same version, everything was fine.

manast commented 3 weeks ago

I did not do that on purpose. I am using a monorepo where one package in the repo had another bull version as another one. As soon as both had the same version, everything was fine.

What it seems to be the culprit for your particular case is that one version of BullMQ is using the Lua script of a different version of BullMQ. AFAIK this should be impossible to happen, as the Lua scripts are mapped by a sha256 key of its contents, so it should not be possible, but clearly somehow it can happen. This is worthy to investigate, as it is reasonable to use different versions of BullMQ against the same Redis instance.