Bull: Getting "client.addJob is not a function" from bull in serverless environment

Created on 5 Aug 2019  路  2Comments  路  Source: OptimalBits/bull

Description

I'm trying to add a job to a queue, but I get this strange error. I tried reading through the source code, searching but didn't find out what could cause it. I'm building using Webpack and tried both bundling and external load. No luck.

Minimal, Working Test code to reproduce the issue.

(An easy to reproduce test case will dramatically decrease the resolution time.)

As soon as I know where it could come from I'll try to put together a mini repo.

Bull version

v3.10.0

Additional information

CleanShot 2019-08-05 at 16 28 40

Most helpful comment

That was the issue @stansv!

For people coming later, if you're on ZEIT Now v2, include this in your now.json config to include *.lua files:

```
{
"builds": [
{
"src": "lambda.js",
"use": "@now/node",
"config": {
"includeFiles": [
"*/.lua",
"../node_modules/bull/lib/commands/.lua",
"./node_modules/bull/lib/commands/
.lua"
]
}
}
]
}
...

All 2 comments

I suppose your real Bull version is 3.10.0.

The addJob is a wrapper function on ioredis instance that should be automatically created with client.defineCommand(). Commands are lua scripts bundled in Bull package. Looks like that your deployed artifact doesn't include these scripts.

Here is the place where it happens https://github.com/OptimalBits/bull/blob/develop/lib/commands/index.js#L43

I didn't used webpack, probably the easiest solution would be to inline contents of each script into JS objects and modify code of loadScripts to eliminate filesystem access.

That was the issue @stansv!

For people coming later, if you're on ZEIT Now v2, include this in your now.json config to include *.lua files:

```
{
"builds": [
{
"src": "lambda.js",
"use": "@now/node",
"config": {
"includeFiles": [
"*/.lua",
"../node_modules/bull/lib/commands/.lua",
"./node_modules/bull/lib/commands/
.lua"
]
}
}
]
}
...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alolis picture alolis  路  4Comments

DevBrent picture DevBrent  路  4Comments

PhillippOhlandt picture PhillippOhlandt  路  4Comments

rodrigoords picture rodrigoords  路  4Comments

NicolasDuran picture NicolasDuran  路  4Comments