Skip to content

fix: finish alert email before the evaluator disconnects Prisma - #687

Merged
cursor[bot] merged 1 commit into
developfrom
cursor/alert-evaluator-email-f4fb
Sep 25, 2026
Merged

cursor[bot] merged 1 commit into
developfrom
cursor/alert-evaluator-email-f4fb

Conversation

@unjica

@unjica unjica commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Base branch: open feature and fix PRs against develop. Not deployed.

Summary

The alert-rules evaluator cron disconnects Prisma as soon as the sweep function returns. fireProjectAlert started notification email with an unawaited call, so the second run (the first one that actually fired a rule) called notificationEmailLog.createMany after prisma.$disconnect(). Prisma then threw Response from the Engine was empty from sendNotificationEmailIfAllowed. The first run did not fire, so it exited cleanly.

createMany itself is fine. The failure is the short-lived cron closing the engine while that query is in flight.

This PR waits for email logging before fireProjectAlert returns, so the cron disconnects only after that query finishes. One recipient's email error is logged and does not reject the rest of the fan-out. One scheduled rule or project failure is logged and does not stop the rest of the sweep. Ingest-triggered rules such as ERROR_COUNT still throw on evaluation failure.

Railway cron settings are unchanged.

How to test

pnpm lint && pnpm test && pnpm build

Checklist

  • Tests pass
  • Lint passes
  • Build succeeds
  • CHANGELOG [Unreleased]
  • No migration
  • Not deployed

Security / privacy

N/A. Email failures are logged with the notification key and address, not message bodies.

Open in Web Open in Cursor 

The cron was closing the Prisma engine while notificationEmailLog.createMany
was still in flight. Wait for that work, and keep one email or rule failure
from stopping the rest of the sweep.

Co-authored-by: Sanja Malovic <[email protected]>
@unjica
unjica marked this pull request as ready for review September 25, 2026 18:10
@cursor
cursor Bot merged commit 8a46e90 into develop Sep 25, 2026
9 checks passed
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.

2 participants