Repository navigation
fix: finish alert email before the evaluator disconnects Prisma - #687
Merged
Merged
Conversation
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
marked this pull request as ready for review
September 25, 2026 18:10
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
fireProjectAlertstarted notification email with an unawaited call, so the second run (the first one that actually fired a rule) callednotificationEmailLog.createManyafterprisma.$disconnect(). Prisma then threwResponse from the Engine was emptyfromsendNotificationEmailIfAllowed. The first run did not fire, so it exited cleanly.createManyitself 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
fireProjectAlertreturns, 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 asERROR_COUNTstill throw on evaluation failure.Railway cron settings are unchanged.
How to test
pnpm lint && pnpm test && pnpm buildChecklist
[Unreleased]Security / privacy
N/A. Email failures are logged with the notification key and address, not message bodies.