Skip to content

Commit

Permalink
fix: bullmq redis errors on build
Browse files Browse the repository at this point in the history
  • Loading branch information
radityaharya authored Apr 21, 2024
1 parent a12df27 commit 5b82794
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Binary file modified bun.lockb
Binary file not shown.
9 changes: 6 additions & 3 deletions src/app/api/workflow/workflowQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Queue } from "bullmq";

import Redis from "ioredis";
import { env } from "~/env";
import { db } from "~/server/db";
import { workflowJobs, workflowRuns } from "~/server/db/schema";
Expand All @@ -8,11 +10,12 @@ import { Logger } from "@/lib/log";

const log = new Logger("workflowQueue");

const connection = new Redis(env.REDIS_URL, {
maxRetriesPerRequest: null,
});

export const workflowQueue = new Queue("workflowQueue", {
connection: {
path: env.REDIS_URL,
},
connection,
defaultJobOptions: {
attempts: 2,
backoff: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/main-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function MainNav() {
onClick={() => resetReactFlow()}
className={cn(
"transition-colors hover:text-foreground/80",
pathname === "/workflow" ? "text-foreground" : "text-foreground/60",
/\/workflow(?!s)/.test(pathname) ? "text-foreground" : "text-foreground/60",
)}
>
Builder
Expand Down
8 changes: 5 additions & 3 deletions src/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ export const register = async () => {
console.log("Registering worker");
console.log("Worker ID", WORKER_ID);
const { Worker } = await import("bullmq");
const Redis = (await import("ioredis")).default;
const updateWorkflowRun = (await import("~/app/api/workflow/workflowQueue"))
.updateWorkflowRun;
const connection = new Redis(env.REDIS_URL, {
maxRetriesPerRequest: null,
});

new Worker(
"workflowQueue",
Expand Down Expand Up @@ -45,9 +49,7 @@ export const register = async () => {
return res.map((obj: any) => obj.track.id);
},
{
connection: {
path: env.REDIS_URL,
},
connection,
concurrency: 5,
removeOnComplete: { count: 1000 },
removeOnFail: { count: 5000 },
Expand Down
Binary file modified worker/bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"@planetscale/database": "^1.11.0",
"@sentry/nextjs": "^7.93.0",
"@types/spotify-api": "^0.0.25",
"bullmq": "^5.1.1",
"bullmq": "^5.7.2",
"drizzle-orm": "latest",
"ioredis": "^5.3.2",
"ioredis": "^5.4.1",
"million": "latest",
"next-auth": "^4.24.5",
"spotify-web-api-node": "^5.0.2",
Expand Down

0 comments on commit 5b82794

Please sign in to comment.