Skip to content

fix(backend): stop swallowing errors in judge enqueue, worker, and startup - #2

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783735167-improve-error-handling
Open

fix(backend): stop swallowing errors in judge enqueue, worker, and startup#2
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1783735167-improve-error-handling

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Review of backend error handling surfaced a few places where errors were silently swallowed or lost. This fixes the ones with real diagnostic/operational impact.

1. Judge enqueue failures were completely swallowed (problems.service.ts, runCode + submitCode). The catch {} discarded the underlying BullMQ/Redis error, so a broken queue only ever showed up as a generic 503 with no log. Worse, the compensating DB update ran unguarded inside the catch — if it threw, the intended JUDGE_UNAVAILABLE (503) got replaced by an opaque 500 and the real cause was hidden twice over.

} catch (error) {
  console.error("Failed to enqueue judge run job", { runId: run.id, error });
  try {
    await prisma.codeRun.update({ ... status: "internal_error" ... });
  } catch (updateError) {
    console.error("Failed to mark code run as internal_error", { runId: run.id, error: updateError });
  }
  throw new AppError(503, "JUDGE_UNAVAILABLE", "The judge is temporarily unavailable.");
}

Client contract is unchanged (still 503 JUDGE_UNAVAILABLE); the difference is the root cause is now logged and the compensating write can't mask it.

2. Worker internal-error persistence could mask the real judge error (judge/queue/worker.ts). In processJudgeJob's catch, await persistInternalError(...) ran unguarded before throw error — a persistence failure would throw and replace the original judge error that BullMQ needs to see. Wrapped it so the original error is always the one propagated.

3. Startup rejection was discarded (server.ts). void bootstrap() dropped any rejection (e.g. ensureImagesUploadDir failing) into a silent unhandled rejection. Now it logs and exits non-zero. Also added unhandledRejection / uncaughtException logging so nothing dies silently.

4. Worker had no error listener (worker.ts). Added worker.on("error", ...) plus the same process-level handlers so BullMQ connection errors are surfaced instead of vanishing.

No behavior change to the HTTP API contract; these only add logging/propagation and harden compensating paths.

Link to Devin session: https://app.devin.ai/sessions/6df705df29f24a919acaf6460fa38e6a
Requested by: @CyberStill-GmbH

…artup

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@CyberStill-GmbH CyberStill-GmbH self-assigned this Jul 11, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
codenix Ready Ready Preview, Comment Jul 11, 2026 2:00am

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.

1 participant