mirror of
https://github.com/labring/sealos.git
synced 2026-08-30 17:58:09 +08:00
f2bb5a88b4
This commit resolves the issue where multiple regions simultaneously process the same invoice.created event, causing Stripe API errors: "This invoice is already finalized, you can't re-finalize a non-draft invoice." Changes: 1. Add region check in handleWorkspaceSubscriptionInvoiceCreated - Only process events belonging to the current region - Skip events from other regions with appropriate logging - Use existing checkIsLocalEvent function for consistency 2. Add fault tolerance in ConfirmInvoice for FinalizeInvoice - Detect "already finalized" errors gracefully - Re-fetch invoice status when finalized by another region - Continue processing instead of failing Impact: - Eliminates race conditions in multi-region deployments - Ensures only one region processes each invoice.created event - Provides graceful fallback for edge cases - Maintains backward compatibility with idempotent behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>