Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: Node.js
error-handlingschedulercronresilience
Wrap scheduled jobs in error handling
Cron/scheduler-triggered tasks should catch and log their own errors so an unhandled rejection doesn't crash the process or fail silently.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | @Cron('0 * * * *') |
| 2 | async run() { |
| 3 | await this.provisionRss(); // unhandled errors escape |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @Cron('0 * * * *') |
| 2 | async run() { |
| 3 | try { |
| 4 | await this.provisionRss(); |
| 5 | } catch (error) { |
| 6 | this.logger.error(error); |
| 7 | } |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)