You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_6 (already cloned)
- Base commit: 63cc6ae2815c465f6f7ee975a6413d314b5df141
- Task ID: juspay__hyperswitch-8733
- Version: v1.115.0
TASK DESCRIPTION: Bug: [BUG] worldpay DDC submission race conditions
Bug Description
Race condition in Worldpay 3DS DDC flow causes
bodyDoesNotMatchSchemaerrors. 8-second timeout inWorldpayDDCFormJS fires before legitimate DDC completion, sendingcollectionReferenceto wrong endpoint (/3dsChallengesvs/3dsDeviceData).Expected Behavior
DDC
collectionReferencesent to/3dsDeviceDataendpoint only. Payment state transitions:DeviceDataCollectionPending→AuthenticationPending→Charged.Actual Behavior
Timeout fires → empty redirect → state advances to
AuthenticationPending→ latecollectionReferencesent to/3dsChallenges→ Worldpay rejects with$.collectionReferencevalidation error.Steps To Reproduce
- Trigger Worldpay 3DS payment with DDC delay >8s
- Observe timeout in
api.rs:build_redirection_form() - Check logs for missing
PaymentsStartbetween redirects - Verify
bodyDoesNotMatchSchemaerror
Context For The Bug
File:
crates/router/src/services/api.rsLine:window.setTimeout(submitCollectionReference, 8000);inWorldpayDDCFormImpact: Intermittent 3DS failures when DDC >8sLog Evidence: 11.6s gap between DDC form serve and timeout redirect proves race condition.
Environment
Worldpay connector, 3DS flow with DDC
Have you spent some time checking if this bug has been raised before?
- I checked and didn't find a similar issue
Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to submit a PR?
Yes, I am willing to submit a PR!
Fix Plan:
Client-side (
api.rs):- Increase timeout:
8000→10000 - Add
ddcProcessedflag to prevent multiple submissions - Handle 3 cases: DDC within 10s (normal), DDC never returns (empty submission), DDC after 10s (ignore)
Server-side (
worldpay.rs):- Accept empty
collectionReferenceinDeviceDataCollectionPendingstate - Ignore late DDC submissions when already in
AuthenticationPendingstate - Add validation to prevent sending
collectionReferenceto/3dsChallengesendpoint
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
Description
Fixes race condition in Worldpay 3DS Device Data Collection (DDC) flow causing
bodyDoesNotMatchSchemaerrors.Changes made:
- Extended DDC timeout from 8s to 10s in client-side JavaScript
- Added
ddcProcessedflag to prevent duplicate submissions on client-side - Reject
collectionReferencesubmissions when payment is inAuthenticationPendingstate - Fixed CSS media query syntax (
@media (max-width: 600px)) - Added Cypress test case for both client and server-side race conditions for DDC submissions
Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
Race condition caused intermittent 3DS payment failures when DDC took > 8 seconds.
How did you test it?
Note
- PSync for WP fails due to 404 and WP sending back a HTML rather than a JSON response (https://github.com/juspay/hyperswitch/pull/8753)
Checklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_6/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll tackle this Worldpay DDC race condition bug systematically. Let me start by examining the relevant files to understand the current implementation and then make the necessary changes.
First, let me look at the specific file mentioned in the bug report - api.rs:
Assistant
Let me search for the WorldpayDDCForm and related JavaScript code in the api.rs file:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →