Back to all reviewers

comprehensive error handling

adonisjs/core
Based on 2 comments
TypeScript

Ensure error handling mechanisms are comprehensive and graceful rather than limited or forceful. Use persistent event listeners (`process.on()`) instead of one-time listeners (`process.once()`) for critical error scenarios to handle all occurrences, not just the first one. Similarly, prefer graceful shutdown methods that allow proper cleanup over forceful...

Error Handling TypeScript

Reviewer Prompt

Ensure error handling mechanisms are comprehensive and graceful rather than limited or forceful. Use persistent event listeners (process.on()) instead of one-time listeners (process.once()) for critical error scenarios to handle all occurrences, not just the first one. Similarly, prefer graceful shutdown methods that allow proper cleanup over forceful process termination.

For signal and exception handling:

// Preferred: Handles all occurrences
process.on('SIGINT', this.kill)
process.on('SIGTERM', this.kill)
process.on('uncaughtException', (error) => {
  // Handle error
})

// Avoid: Only handles first occurrence
process.once('SIGINT', this.kill)

For application shutdown:

// Preferred: Graceful shutdown with cleanup
await this.application.shutdown()

// Avoid: Forceful termination
await this.exit()

This approach ensures that all error scenarios are properly handled and allows applications to clean up resources gracefully, preventing issues like interrupted stdout or incomplete cleanup operations.

2
Comments Analyzed
TypeScript
Primary Language
Error Handling
Category

Source Discussions