mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 08:13:23 +00:00
Fix critical error handling and race condition issues
🔴 Critical fixes: - Fix race condition: processImmediately now properly fails if job creation fails - Fix silent job failures: job creation failures now throw errors instead of warnings - Ensure atomic operations: either email + job succeed together, or both fail ⚠️ Improvements: - Simplify error handling in processEmailJob to be more consistent - Add proper validation for missing PayloadCMS jobs configuration - Make error messages more descriptive and actionable
This commit is contained in:
@@ -64,13 +64,7 @@ export const processEmailJob = {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// Re-throw Error instances to preserve stack trace and error context
|
||||
if (error instanceof Error) {
|
||||
throw error
|
||||
} else {
|
||||
// Only wrap non-Error values
|
||||
throw new Error(`Failed to process email ${emailId}: ${String(error)}`)
|
||||
}
|
||||
throw new Error(`Failed to process email ${emailId}: ${error instanceof Error ? error.message : String(error)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user