Skip to content

fix: prevent promo code over-redemption race condition - #98

Open
Inkcha wants to merge 2 commits into
profullstack:masterfrom
Inkcha:fix/promo-race-condition
Open

fix: prevent promo code over-redemption race condition#98
Inkcha wants to merge 2 commits into
profullstack:masterfrom
Inkcha:fix/promo-race-condition

Conversation

@Inkcha

@Inkcha Inkcha commented Jul 27, 2026

Copy link
Copy Markdown

Description

Race condition in promo code redemption: two concurrent requests could both pass the duplicate SELECT check before either INSERT executes, allowing the code to be redeemed N+1 times instead of once.

Fix

Removed the duplicate SELECT check in quotePromo() — the INSERT (composite PK on code+user_id) is atomic and will fail if the redemption already exists. The catch in recordPromoRedemption handles this naturally.

Related

Fixes #92

Inkcha added 2 commits July 27, 2026 19:43
getCoinpayPayment() and createPayment() silently swallowed all
errors and returned null. This made payment failures invisible —
a temporary CoinPay API outage would silently deny users their
paid entitlements with no alert.

Added console.error logging so operational issues are visible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MEDIUM: Race condition in promo code duplicate redemption check

1 participant