Network Error Logging: Capturing Connection Drops
Network Error Logging (NEL) is a modern web standard that enables web applications to collect detailed telemetry on network-level failures directly from the user’s browser. While traditional JavaScript-based monitoring relies on successful page loads and active script execution, NEL operates at the browser level, allowing developers to capture critical connection drops, DNS resolution failures, and TLS handshake errors that would otherwise go unnoticed. This article explains the fundamentals of NEL, the limitations of standard JavaScript error handling, and how NEL buffers and delivers diagnostic reports during connectivity failures.
The Limitation of JavaScript Error Tracking
Standard client-side error monitoring in JavaScript typically relies
on try...catch blocks, window.onerror, or
intercepting fetch() and XMLHttpRequest
failures. While effective for application-level logic errors, this
approach has a severe blind spot: the network infrastructure itself.
If a user experiences a connection drop during the initial page navigation, DNS lookup, or TLS negotiation, the HTML and JavaScript assets never load. Consequently, client-side monitoring scripts cannot execute or report the failure. Even if a script detects a dropped background request, it often cannot transmit the error telemetry back to an analytics server over the compromised connection.
What is Network Error Logging (NEL)?
Network Error Logging is a W3C specification designed to provide automated, browser-native reporting of network reliability issues. Instead of relying on client-side code, NEL is configured via HTTP response headers delivered by the origin server.
Once configured, the browser natively monitors all network requests—including initial document navigations, API calls, and sub-resource requests. If a network-level error occurs, the browser generates a structured JSON report containing diagnostic details about the failure.
How NEL Works
To enable NEL, a server delivers two specific HTTP response headers on a successful connection:
Reporting-Endpoints(or legacyReport-To): Defines the reporting collector URL where telemetry payloads should be sent.NEL: Defines the logging policy, specifying the target endpoint group, policy duration (max_age), success/failure sampling rates, and whether subdomains are included.
An example header configuration looks like:
Reporting-Endpoints: nel-endpoint="https://analytics.example.com/nel"
NEL: {"report_to": "nel-endpoint", "max_age": 2592000, "failure_fraction": 1.0}
Capturing Connection Drops
NEL reliably captures connection drops and network interruptions through several built-in mechanisms:
- Browser-Native Persistence: Because NEL policies are stored in the browser’s persistent cache, the policy remains active across page refreshes and browser restarts, even if the application fails to load on subsequent visits.
- Offline Queuing: When a connection drops, the browser cannot immediately transmit the error report. NEL solves this by queuing generated reports locally in browser storage.
- Out-of-Band Delivery: The browser automatically
batches and transmits the queued failure reports once network
connectivity is re-established, sending them in an out-of-band
POSTrequest to the configured collector endpoint. - Granular Failure Types: NEL payloads classify exact
failure states, such as
tcp.timed_out,tcp.refused,dns.name_not_resolved,tls.version_or_cipher_mismatch, andhttp.response.invalid.
By moving error capture from the application runtime to the browser engine, Network Error Logging provides comprehensive visibility into edge routing issues, ISP disruptions, and dropped connections across all web platforms.