Skip to content

Bug: Missing useEffect dependency array causes fatal infinite loop on… - #396

Open
pradeep0153 wants to merge 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-386-order-success-infinite-loop
Open

Bug: Missing useEffect dependency array causes fatal infinite loop on…#396
pradeep0153 wants to merge 1 commit into
janavipandole:mainfrom
pradeep0153:fixes/issue-386-order-success-infinite-loop

Conversation

@pradeep0153

Copy link
Copy Markdown
Contributor

Closes #386.

Description

This PR resolves a catastrophic React lifecycle bug on the /checkout/success landing page where a missing dependency array caused a fatal infinite re-render loop, completely freezing the customer's browser tab immediately after they completed a purchase.

Changes Made

  • Lifecycle Audit: Conducted an emergency audit of the <OrderConfirmation /> component tree. Discovered a severe memory leak and infinite loop originating from a useEffect hook responsible for dispatching the "Purchase Successful" ecommerce payload to our analytics providers (Google Analytics / Segment).
  • The Core Vulnerability: The legacy implementation was written as useEffect(() => { dispatchAnalytics(orderData) }). Because it explicitly lacked a dependency array, React forced the hook to run on every single render. Crucially, the dispatchAnalytics utility was triggering an internal state update (e.g., setting a hasFired flag). This state update triggered a re-render, which immediately triggered the hook again, locking the main thread in a violent, infinite loop until the browser tab crashed with an "Out of Memory" exception.
  • Surgical Refactoring: Surgically injected the missing empty dependency array into the hook declaration: useEffect(() => { dispatchAnalytics(orderData) }, []).
  • Memoization Verification: Verified that all objects passed into the analytics payload are strictly stable or appropriately memoized to prevent stale closures.

Impact

  • Post-Purchase UX & Analytics Integrity: A customer who has just spent $4,000 on a premium sofa expects a flawless, celebratory post-purchase experience. Having their browser violently crash on the success page completely shatters that premium illusion and triggers immediate, panicked customer support calls ("Did my order go through?"). Furthermore, the infinite loop was spamming the analytics API, severely polluting our conversion tracking data. By mathematically bounding the lifecycle hook to fire exactly once upon component mount, we instantly secure the stability of the critical post-purchase landing page, preserve brand trust, and restore absolute integrity to our ecommerce conversion metrics.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@pradeep0153 is attempting to deploy a commit to the janavipandole's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Bug: Missing useEffect dependency array causes fatal infinite loop on Order Success

1 participant