Copyright © 2014 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
This specification defines an interface to store and retrieve error data related to the previous navigations of a document.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This is document is the First Public Working Draft of the Navigation Error Logging specification.
Please send comments to public-web-perf@w3.org (archived) with [NavigationErrorLogging] at the start of the subject line.
This document is produced by the Web Performance Working Group. The Web Performance Working Group is part of the Rich Web Clients Activity in the W3C Interaction Domain.
Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This section is non-normative.
Accurately measuring performance characteristics of web applications is an important aspect in helping site developers understand how to make their web applications faster. Likewise, measuring and understanding when web applications are not properly loading for end users due to network errors is an example of the worst case web browsing performance.
Today, site developers do not have real time web application availability data from their end users. Synthetic testing cannot truly provide global or near real-time availability data for real end users.
For example, a user visits http://example.com, causing the User Agent to send a HTTP request to the server. The server has a memory bug that causes a random set of responses to have a space in the middle of the HTTP response header, like so:
HTTP/1. 1 200 OK Date: Thu, 24 Jan 2015 05:46:54 GMT Content-Length: 2291 Content-Type: text/html
In this example, the seventh character of the first response, incorrectly has a space
(e.g., HTTP/1. 1
should be HTTP/1.1
). When the server sends this response, this causes
strict format validation issues at the CDN near the user to fail to process the
request. So while the server sees a 200 OK HTTP response, the end user actually sees
a 500 Server Error HTTP response.
The previous example described a case where the site developers may not actually know that end users are hitting this problem for quite some time. As the issue is random, it may not be caught by synthetic testing.
To address the need for detailed information on the errors resulting from the navigation of the document, the Navigation Error Logging specification defines the NavigationErrorEntry interface. This interface allows JavaScript mechanisms to provide client-side error data on the previous navigations of the document within the applications. As it is typically impossible to obtain error data through JavaScript mechanisms during an aborted navigation due to the error, this data is persisted across sessions. The interface also allows a web developer to specify a error reporting url that the user agent can use to upload error data to in real time on a navigation error.
The following script shows how a developer can use the NavigationErrorEntry interface to obtain accurate error timing data related to the previous navigations of the document.
<!doctype html> <html> <head> </head> <body onload="init()"> <script> function onNavigationErrorsReceived(errorList) { for (i = 0; i < errorList.length; i++) { if (window.console) console.log("Document: " + errorList[i].name + "\n" + "Error Type: " + errorList[i].errorType + "\n" + "Time of Error (UTC): " + new Date(errorList[i].startTime) + "\n" + "Duration: " + errorList[i].duration); } } function init() { window.performance.getNavigationErrors(onNavigationErrorsReceived); } </script> </body> </html>
All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. For readability, these words do not appear in all uppercase letters in this specification.
Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.
Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)
The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [Web IDL]
The construction "a Foo
object", where Foo
is actually an interface, is sometimes used instead of
the more accurate "an object implementing the interface Foo
".
The term "navigation" refers to the act of navigating.
The term "JavaScript" is used to refer to ECMA-262, rather than the official term ECMAScript, since the term JavaScript is more widely known.
This section is non-normative.
This specification defines the NavigationErrorEntry interface to store and retrieve error data related to previous navigations of a document.
NavigationErrorEntry
interfaceinterface NavigationErrorEntry { readonly attribute DOMString name; readonly attribute DOMTimeStamp startTime; readonly attribute DOMTimeStamp duration; readonly attribute NavigationErrorType errorType; }; enum NavigationErrorType { "dns", "tcp", "ssl", "http", "abandoned" };
name
attribute
The name
attribute MUST return the current address
of the document where the error occurred, as an absolute URL.
startTime
attribute
The startTime
attribute MUST return a DOMTimeStamp
with the time immediately after the user agent finishes prompting
to unload the previous document while navigating to the document that resulted in an error.
duration
attribute
The duration
attribute MUST return a DOMTimeStamp
equal to the difference between the time immediately after the User Agent logs the occurrence of the error and startTime.
errorType
attribute
This attribute MUST return one of the following strings describing the type of the error: dns
, tcp
, ssl
,
http
, and abandoned
. The abandoned
error type refers to the case where the user aborts the navigation before it is complete.
Performance
Interfacepartial interface Performance { void enableNavigationErrorReporting(DOMString reportUrl); void disableNavigationErrorReporting(); void enableNavigationErrorLogging(boolean enable); void getNavigationErrors(GetNavigationErrorsCallback getnavigationerrorscallback); void clearNavigationErrors(); typedef sequence <NavigationErrorEntry> NavigationErrorEntryList; }; callback GetNavigationErrorsCallback = void (NavigationErrorEntryList navigationerrorentrylist);
enableNavigationErrorReporting
methodThe enableNavigationErrorReporting
method, when invoked, enables reporting of future navigation errors for the origin of the current document to the resolved URL provided by the reportUrl
parameter. This setting must be persisted across sessions.
When a navigation to a url in the given origin fails, the user agent MUST fetch reportUrl
, with the synchronous flag not set, using HTTP method POST, with a Content-Type header field of application/json with an entity body consisting of the JSON stringification of the NavigationErrorEntry object corresponding to the failed navigation. The user agent MUST not follow redirects when fetching this and ignore the response. If the fetch of reportUrl
itself fails, the user agent MUST not retry fetching reportUrl
.
Parameters
inreportUrl
type of DOMString
The reportUrl
parameter indicates the resolved URL
where the error data is to be sent. The User Agent MUST throw the
URLMismatchError exception
if the URL cannot be resolved.
No return value
No additional exceptions
disableNavigationErrorReporting
methodThe disableNavigationErrorReporting
method, when invoked, disables reporting of navigation errors for the origin of the current document. This setting must be persisted across sessions.
No Parameters
No return value
No additional exceptions
enableNavigationErrorLogging
methodThe enableNavigationErrorLogging
method, when invoked, enables or disables logging of navigation errors, based on whether enable
is true
or false
, respectively, for the origin of the current document. This setting must be persisted across sessions.
The user agent should limit the total number of NavigationErrorEntry objects stored for a given origin. A limit of 150 entries is recommended.
Parameters
inenable
type of boolean
The enable parameter enables or disables logging of navigation errors.
No return value
No additional exceptions
getNavigationErrors
methodThe getNavigationErrors
method calls back the provided callback with a
NavigationErrorEntryList
object that contains a copy of all NavigationErrorEntry
objects
for the origin of the current document in chronological order.
Parameters
ingetnavigationerrorscallback
type of GetNavigationErrorsCallback.
No return value
No additional exceptions
clearNavigationErrors
methodThe clearNavigationErrors
method clears the buffer used to store the
list of NavigationErrorEntry objects.
No parameters
No return value
No additional exceptions
The value of the timing attributes must monotonically increase to ensure timing attributes are not skewed by adjustments to the system clock while recording error data. The difference between any two chronologically recorded timing attributes must never be negative.
This section is non-normative.
The NavigationErrorEntry interface exposes timing and other information for an error that has occurred in the previous navigations to the web page. Access to the NavigationErrorEntry interface is limited to the same origin.
The user agent mechanisms used to delete private data such as history or cookies for a given origin or as a whole should also delete the corresponding NavigationErrorEntry objects.
We would like to offer our sincere thanks to Aaron Heady, Daniel Austin, James Simonsen, Philippe Le Hegaret, and Jason Weber for their contributions to this work.