quirrel icon indicating copy to clipboard operation
quirrel copied to clipboard

CronJob duplicates on Vercel

Open markkkkas opened this issue 2 years ago • 1 comments

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"
  }
}

CleanShot 2022-09-01 at 22 24 49

Thank you in advance!

markkkkas avatar Sep 01 '22 19:09 markkkkas

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.

Skn0tt avatar Sep 13 '22 19:09 Skn0tt

Closing this, feel free to reopen.

Skn0tt avatar Oct 18 '22 07:10 Skn0tt

Hey @Skn0tt, sorry for late reply I cannot reopen, so im writing it here.

Im currently using this setup:

  1. Vercel for next.js app
  2. Self-hosted quirrel on netlify

Build command: "build:vercel": "next build && quirrel ci"

As you can see, quirrel tried to update cron jobs image

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... image

image

image

markkkkas avatar Nov 30 '22 11:11 markkkkas

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 avatar Nov 30 '22 12:11 Skn0tt

@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.

markkkkas avatar Nov 30 '22 12:11 markkkkas

@Skn0tt looks like that we managed to fix it! Thank you very much for support.

markkkkas avatar Nov 30 '22 12:11 markkkkas