DEV Community

upordown.online
upordown.online

Posted on Edited on

How to read a HAR file when someone says "the site is broken for me"

Uptime monitoring from outside your own infrastructure that alerts you the minute your site goes down — upordown.online

"It's broken for me" is the hardest kind of bug report. It works on your machine, your monitors are green, and the user can't describe much beyond a blank page or a spinner. Screenshots help a little. A HAR file helps a lot.

A HAR (HTTP Archive) file is a JSON recording of every request the browser made while loading a page: URLs, status codes, headers, timings, and often the response bodies. It shows you the page load from the user's network, with their DNS, their extensions, their proxy and their CDN edge. That's usually exactly the part you can't reproduce.

Asking for a HAR file without leaking secrets

HAR files contain cookies, authorization headers and sometimes form data. A HAR file from a logged-in session can be enough to take over that session. So:

  • Ask the user to reproduce in a fresh Incognito or private window, logged out if the bug allows it.
  • Tell them to export the sanitised version. Recent Chrome versions export HAR files with sensitive data (cookies, Authorization headers) removed by default; the option to include it is a separate, deliberate choice. Firefox and Safari don't always do this, so mention it.
  • Delete it when you're done, and never attach it to a public issue.

The steps for Chrome: open DevTools (F12), go to the Network tab, tick "Preserve log", reload the page and reproduce the problem, then use the download arrow icon ("Export HAR"). In Firefox it's the gear icon in the Network panel, then "Save All As HAR".

What to look at first

You can open a HAR file by dragging it into the Network tab of Chrome DevTools, which gives you the familiar waterfall view. Then work through these in order.

1. Failed and blocked requests

Sort by status. Look for:

  • Status 0 or "(failed)": the request never got a response. DNS failure, connection reset, blocked by an extension, CORS rejection, or a timeout. The _error field (Chrome-specific) often says which, for example net::ERR_NAME_NOT_RESOLVED or net::ERR_BLOCKED_BY_CLIENT.
  • 4xx and 5xx responses on API calls or assets your page depends on.
  • Requests to unexpected hosts. A browser extension or a corporate proxy injecting scripts shows up here.

2. The timing breakdown of the slow requests

For each request, a HAR file records time spent in phases: blocked, dns, connect, ssl, send, wait, receive. This is where "it's slow for me" becomes a diagnosis:

  • Large dns: the user's resolver is slow or failing over.
  • Large connect or ssl: network path problems, packet loss, or a far-away CDN edge.
  • Large wait: your server took a long time to start responding. That one is on you.
  • Large blocked: the browser was queueing requests, often too many on one connection or a busy main thread.

3. Which server answered

Response headers usually tell you which CDN edge, load balancer or backend handled the request: server, via, x-cache, cf-ray, x-served-by, x-amz-cf-pop. If the user's requests went to an edge in a different region than yours, or got a cached error (x-cache: HIT on a 503), you've found why it works for you and not for them.

The serverIPAddress field shows the IP the browser connected to. Compare it with what your DNS returns. A stale or wrong IP points at the user's DNS cache, their hosts file, or a resolver that has an old record.

A HAR file shows one person's path; an outside check shows everyone else's. upordown.online tells you whether the failure is local or the site itself is down.

A short script to summarise a HAR file

Clicking through 300 requests gets old. This prints the failures and the slowest requests, with the phase that took longest:

import json, sys
from urllib.parse import urlsplit

har = json.load(open(sys.argv[1], encoding="utf-8"))
entries = har["log"]["entries"]
phases = ["blocked", "dns", "connect", "ssl", "send", "wait", "receive"]

print("== failures")
for e in entries:
    status = e["response"]["status"]
    if status == 0 or status >= 400:
        err = e["response"].get("_error") or ""
        print(status, err, e["request"]["url"][:120])

print("\n== slowest 10")
for e in sorted(entries, key=lambda e: -e["time"])[:10]:
    t = e["timings"]
    worst = max(phases, key=lambda p: t.get(p, -1) or -1)
    host = urlsplit(e["request"]["url"]).netloc
    print(f'{e["time"]:8.0f} ms  {worst:8s} {t.get(worst, 0):7.0f} ms  '
          f'{e["response"]["status"]}  {host}  {e.get("serverIPAddress", "")}')
Enter fullscreen mode Exit fullscreen mode

Run it with python3 har_summary.py user.har. In most cases, the first few lines tell you which of the three questions above to dig into.

Compare two HAR files

When something works for you and fails for the user, capture your own HAR of the same page and compare. Differences in serverIPAddress point to DNS or routing. Different x-cache or edge identifiers point to a CDN edge problem. Requests that exist in theirs but not yours point to an extension or injected script. A request that fails only in theirs, with the same IP and headers as yours, points to something on their network, such as a firewall or a corporate proxy. Putting the two summaries from the script side by side usually narrows it to one of these in a few minutes.

Three patterns that come up again and again

  • One host fails, everything else works. A third-party script, a font CDN, or your own API on a separate subdomain is blocked or unreachable for that user. The page waits on it and appears broken.
  • The HTML loads, every asset fails. Often a stale cached HTML page referencing asset filenames that were deleted in the last deploy, or a CDN edge with a bad cache.
  • Everything is slow in connect and ssl. The user's network is the problem. You can't fix it, but you can tell them that with confidence.

A HAR file covers one user at one moment. To know whether the problem is wider than that person, compare it with checks from several locations: an external monitor such as upordown.online shows whether the same URL fails from other networks.

Related reading

What's the strangest thing you've found in a user's HAR file? I once found a browser extension rewriting every API call to a different domain.

Top comments (0)