← All work

Catching payment pages that load blank · Dec 2024 – Jan 2025

Knowing when the payment page fails to load

Server logs said our hosted payment page was fine. But a payment page can return 200 OK and still show a customer nothing at all, if the app itself never starts. I built a small check that notices when that happens and tells the team, with enough detail to follow up on that payment.

Role
Frontend engineer
When
Dec 2024 – Jan 2025
Where
PayGlocal
Stack
JavaScriptReactnginxAlerting

The situation

A December review of the payment page’s performance listed a gap: we couldn’t detect a page break. The page is a single-page app. The server sends a short HTML document, and the real interface only appears once the JavaScript bundle downloads and boots. If that bundle is blocked, fails to download, or hits a browser it can’t run in, the customer sees a blank page. The server has already answered 200 OK, so from the outside everything looks healthy. A customer stuck on a blank payment page simply leaves, and nobody finds out.

What I built

  • A tiny loader script that runs before the app, in plain JavaScript with no framework, so it still runs when the app can’t. It reads the payment session token from the URL.
  • A “loaded” flag the app sets on the window as soon as it boots. It’s defined as read-only and can’t be redefined or deleted, so no other script on the page can fake a healthy load.
  • The check itself: if the flag never appears, the loader reports a load error along with the session token, so the team can see which payment was affected.
  • Alerting: I asked our DevOps team for an alert on that load error, and raised an infrastructure ticket for an email alert as well.
  • Testing across devices and browsers, since an old or unusual browser is exactly where a page is most likely to break.
  • Alongside it, a small server config change so the page is served correctly when a payment flow arrives with a form POST rather than a normal GET.
Try it

Play a page load

Server logs

GET /pay … 200 OKLooks healthy

Customer’s screen

Pay ₹2,499Blank page

The team

No alert neededLoad error alert
with the session token
  1. 1
    Browser receives the payment page

    The server answers 200 OK. As far as server logs go, all is well.

  2. 2
    A tiny loader script runs first

    Plain JavaScript, no framework, so it runs even if the app can’t. It reads the session token from the URL.

  3. 3
    The app bundle loads and boots

    If it starts, it sets a locked “loaded” flag on the window.

  4. 4
    The loader checks the flag

    Flag present: nothing to do. Flag missing: the page is broken for this customer.

  5. 5
    The loader reports a load error

    With the session token, so the failed payment can be traced.

  6. 6
    Alerting picks it up

    An alert for the team, and an email alert as well.

Why the flag is locked

If any script on the page could set the flag, a broken app could look healthy. So it’s defined once, read-only and impossible to redefine.

Object.defineProperty(window, 'appLoaded', {
  value: true,
  writable: false,      // can't be changed
  configurable: false,  // can't be deleted or redefined
});
Press the button to run appLoaded = false and a redefine against a locked object.

Decisions

Check from outside the app

An app can’t report that it failed to start, because if it failed, none of its code ran. The check had to live in a separate, dependency-free script that runs whether or not the app does.

Make the healthy signal impossible to fake

A flag any script could set is a flag you can’t trust. Defining it once, read-only and non-configurable, means a broken page can’t accidentally look fine.

Report with context, not just a count

Sending the session token with the error turns “something failed somewhere” into “this payment failed to load”, which the team can actually act on.

Let alerting do the watching

A log line nobody reads helps no one. Wiring the error into an alert and an email means a broken page gets noticed, not just recorded.

Outcome

WhatBeforeAfterDetail
Blank payment pagesinvisible to monitoringreported with the sessiondetectable
Team notifiednoalert + emailon every load error
Size of the check~100 linesno dependencies
↑↓ move↵ openesc close