Skip to content

fix: resolve stuck Next.js ingestion queue jobs - #55

Open
Akshatshukla-25 wants to merge 1 commit into
madhav2348:mainfrom
Akshatshukla-25:fix/nextjs-stuck-queue-jobs
Open

fix: resolve stuck Next.js ingestion queue jobs#55
Akshatshukla-25 wants to merge 1 commit into
madhav2348:mainfrom
Akshatshukla-25:fix/nextjs-stuck-queue-jobs

Conversation

@Akshatshukla-25

Copy link
Copy Markdown

Summary: Describe your changes

This PR resolves the stuck Next.js ingestion queue jobs issue by implementing a global singleton pattern for the server runtime, triggering the queue worker properly in drainQueue, and passing job IDs to update pipeline stages in real time.

Issue ticket number and link

Closes #41

Changes

  • Modified src/server/runtime.ts to implement a globalThis singleton for all runtime services (queue, pipeline, repository, vector index, processed storage, and worker). This ensures that separate Next.js route bundles/compilations share the exact same state in memory.
  • Updated drainQueue in src/server/runtime.ts to call worker.trigger() instead of manually invoking pipeline.process, which bypassed the queue's internal list (this.order).
  • Modified src/server/services/workers/queueWorker.ts to pass job.id to pipeline.process(job.payload, job.id), enabling status and stage updates (like ocr, vision, tagging) to be recorded on the queue and rendered live in the UI dashboard.

Testing

  • Tested locally (describe steps)
    • Started the Next.js dev server with npm run dev.
    • Sent a screenshot file upload using curl -X POST -F "file=@public/logo.png" -F "sourceType=local" http://localhost:3000/api/screenshots.
    • Checked logs to confirm QueueWorker picked up and successfully completed processing.
    • Queried the job status /api/screenshots/<jobId> to verify status transitions to "processed".
    • Verified TypeScript compilation using npm run backend:check (successful).

Checklist before requesting a review

  • Code follows the project's TypeScript style conventions
  • No secrets or .env values are committed
  • I have performed a self-review of my code
  • CI passes

@github-actions

Copy link
Copy Markdown

🎉 Thanks for submitting a PR, @Akshatshukla-25!

Please confirm the following checklist before review:

  • ⭐ I have starred this repository
  • 🍴 I have forked this repository
  • 📖 I have read the Contributing Guidelines
  • 🔀 My changes are pushed to the develop branch

A maintainer will review your PR shortly. Thank you! 🚀

@Akshatshukla-25

Copy link
Copy Markdown
Author
  • ⭐ I have starred this repository
  • 🍴 I have forked this repository
  • 📖 I have read the Contributing Guidelines
  • 🔀 My changes are pushed to the develop branch

@madhav2348

madhav2348 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

You didn't read contribution guidelines, please follow guidelines

@madhav2348

Copy link
Copy Markdown
Owner

🎉 Thanks for submitting a PR, @Akshatshukla-25!

Please confirm the following checklist before review:

  • ⭐ I have starred this repository
  • 🍴 I have forked this repository
  • 📖 I have read the Contributing Guidelines
  • 🔀 My changes are pushed to the develop branch

A maintainer will review your PR shortly. Thank you! 🚀

@Akshatshukla-25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Next.js Ingestion Queue Jobs Remain Stuck (No Background Worker Active)

2 participants