quirrel
quirrel copied to clipboard
CronJob duplicates on Vercel
Bug Report
Current Behavior
Currently I have one CronJob
which works fine, but when i redeploy my "production" environment in Vercel, using documentation provided method I see duplicated CronJob
in my ui.quirrel.dev webpage.
Is this behaviour expected, or "old" CronJob
instances should be cleaned up after new deployment?
Input Code
Just regular CronJob
import { CronJob } from "quirrel/next";
export default CronJob(
"api/customCron",
async () => {
// await ...
}
)
Expected behavior/code
I expect that old CronJob
instances should be deleted and only one is visible in ui.quirrel.dev webpage.
Environment
- Quirrel version: 1.9.2
- Node/npm version: node 16/pnpm 7.9.5
- Nextjs 12.2
- Vercel
Additional context/Screenshots package.json
{
"scripts": {
"build:vercel": "next build && quirrel ci"
}
}
Thank you in advance!
quirrel ci
is supposed to clean up old cronjobs, that's right. Here's the code: https://github.com/quirrel-dev/quirrel/blob/2feba926bc3836a4f0cb40f63b3ffe65aa9ee2eb/src/api/scheduler/jobs-repo.ts#L301-L356
Not sure what's causing this. Could you try to write up some a minimal reproduction steps that I can use to reproduce this issue? That'd make it a lot easier for me to help you on this.
Closing this, feel free to reopen.
Hey @Skn0tt, sorry for late reply I cannot reopen, so im writing it here.
Im currently using this setup:
- Vercel for next.js app
- Self-hosted quirrel on netlify
Build command: "build:vercel": "next build && quirrel ci"
As you can see, quirrel tried to update cron jobs
And unfrotunately UI shows 2 jobs, which are actually executed 2 times, so if i rerun this, it will be 3 jobs, 4 jobs and etc...
Self-hosted quirrel on netlify
Could you elaborate on how you set that up? I'm not aware of any way of hosting the Quirrel app on Netlify, so it'd be very interesting to learn what you mean by this.
And unfrotunately UI shows 2 jobs,
I have the suspicion that these two jobs, which are seemingly to the same URL, share the same path but have different hosts. The UI only shows the path, but if you hover over it, the tooltip should show the full URL. My suspicion is that one is https://preview-a.vercel.app/api/populate-patients/cron
and the other is https://preview-b.vercel.app/api/populate-patients/cron
, or something similar. That breaks Quirrel's cron deduplication.
If that's the case, check if the QUIRREL_BASE_URL
variable is the same for all your deployments. quirrel ci
relies on that to properly deduplicate.
@Skn0tt Sorry for confusing you, it's not Netlify, its fly.io. I followed this approach https://dev.to/remixtape/self-hosting-quirrel-5af7
Regarding the QUIRREL_BASE_URL
looks like im missing it! Ill try to add it and then will try to redeploy.
@Skn0tt looks like that we managed to fix it! Thank you very much for support.