-
Notifications
You must be signed in to change notification settings - Fork 405
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
Vercel add Job : TypeError: client.addJob is not a function #469
Comments
I'm encountering the same error (works locally, fails on Vercel). This issue seems somehow related: #79 |
I've done some research, and my guess right now is that the I've tried to use I'll continue looking for a solution/workaround later in the week. Related: |
I do not know how vercel works but my feeling is that the deployment is missing the lua files: https://github.com/taskforcesh/bullmq/tree/master/src/commands |
Yes, I think that's correct. I've tried different workarounds but had issues including the lua files along the functions. For now, I've downgraded from |
https://github.com/OptimalBits/bull/tree/develop/lib/commands They all use lua files, why bull works but bullmq doesn't? |
I found a workaround for this while customizing the vercel.json file. Hope to be able to help anyone who is having this problem.
|
Yeah, that's very strange! I don't have enough time to dive deep into the issue but that seems like a useful data point during debugging. I've seen |
@manast @naicoi2407 I've found that when this occurs it is either due to: BullMQ (and Bull) are the final package I have not been able to bundle in my stack. The bundling process generally always completes, but when you run the application you receive:
|
Just did a quick check, if it's possible to repair these, it will likely fix this issue: $ madge --circular dist/index.js |
repair what? I do not get the problem. |
When a bundler runs (ie As an example of some on that list, these are the root cause: (In fact, looking at that list, the above should solve most of them). If interested in making sure the package is able to be bundled, I have found it super useful to run {
"scripts": {
"madge": "madge --orphans -j dist/index.js && madge --circular -j dist/index.js"
}
} or - name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn build
npx madge --orphans -j dist/index.js && madge --circular -j dist/index.js
npx semantic-release |
hmm, I cannot see the circular dependency, for example in the first case: https://github.com/taskforcesh/bullmq/blob/master/src/classes/job.ts#L6 |
It is occuring when the code path attempts to import from "./" (shorthand for "./index.ts") as the path for "job.ts" which is importing from "./" is itself exported from "./" If you switch that line to import each class from it's own relative path it will remove the circular reference. Eg import { Backoffs } from "./backoffs"
import { QueueEvents } from "./queue-events" |
ok, but thats not circular dependencies, thats sounds more like a bug in webpack that is not handling file references correctly. Nevertheless we can do that change to workaround the problem. |
https://stackoverflow.com/a/49117079 |
🎉 This issue has been resolved in version 1.20.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I had the exact same problem (NextJS API routes on Vercel), and tried to upgrade to 1.20.4 as mentioned, but the release does not solve the issue at all. The workaround (custom vercel.json) does not work either.
|
@gendronb I am not a vercel user, but the error as mentioned above is due .lua files not being copied correctly, the workaround should work but you can check if the files were copied or not to the correct place. |
@manast thanks for your quick reply, I have reached the same conclusion (missing lua files)... I will to ask Vercel for help, as these files are not present in the deployed files. |
Have to mention that I'm using NextJS wirth Vercel, so it may be a situation particular to NextJS... |
@gendronb Have you tried using the previous version (bull vs bullmq)? I'd encourage you to just try with a single function. I know it's not a proper solution but if you're on a schedule, it might help you in the short term. Also, if you'll hear back from Vercel on that issue, I'd appreciate if you could repost the response here, I'm also interested. Thanks! |
@manast will do (downgrade to bull) and keep you informed, thanks again for your help! |
I had the same issue with esbuild. I solved it by declaring bullmq as external |
Confirming this workaround for bull on Next.js v11:
Why this works? Have little to no idea. I had 0 issues with Heroku running NextJS with Bull for over a year, but Vercel's build must be more strict and it's parsing out these Lua files. To make matters worse, I didn't get a nice error message in the Vercel logs at all. Sorry, this problem was a tough one. Spent too much time on it. |
@ctrlaltdylan any chances to report this issue to the Vercel team? |
@manast sorry for taking so long to reply... I did downgrade to bull (v4.5), and it's working perfectly on Vercel (with Next 11) without any workaround. |
Yes will do. |
Weird @
Weird, I'm using |
@ctrlaltdylan Weird indeed... My repo is https://github.com/gendronb/next-bullmq/tree/bull, very simple, a single API route (GET NOTE : use the Actual deployment: https://next-bullmq-a6hrefhj5-gendronb.vercel.app/api/jobs/add I can see the jobs being added in the Upstash console. |
Yup I did something similar in my app. I would get a 200 response, I |
The issue is this dynamic bullmq/src/commands/script-loader.ts Line 395 in 86e84df
If this could be changed to |
This cannot be changed currently because |
I had a similar error, and similarly wound up in this thread. But my problem was actually that Upstash doesn't support |
Upstash is going to be compatible very soon, when they support Redis Streams which is almost ready. |
Thanks for developing this open source. I really enjoy it.
I have encountered this problem when running on vercel serverless.
The source code works perfectly fine on local.
Example Code:
The text was updated successfully, but these errors were encountered: