CrashReport

The CrashReport dictionary of the Reporting API represents a crash report.

Note: It is not possible to retrieve crash reports using a ReportingObserver — the reports are only generated when the browser crashes, at which point the observer code isn't available to run.

Instance properties

age

The age of the report in milliseconds.

type

The string "crash" indicating that this is a crash report.

url

A string representing the URL of the document that generated the report.

user_agent

The user agent string of the browser that generated the report.

body

The body of the report. This is an object with the following properties:

crash_report_api Experimental Optional

An object containing the key-value pairs set via the CrashReportContext.set() method, if any.

is_top_level Experimental

A boolean indicating whether the crashed document was a top-level document (true) or an embedded document (false).

reason Experimental Optional

A string indicating the specific reason why the crash occurred, if known. Possible values are:

oom

The page ran out of memory.

unresponsive

The page was killed due to being unresponsive.

stack Experimental Optional

A string representing the JavaScript call stack at the time of the crash. This is included if the reason is unresponsive, if the Document-Policy value for include-js-call-stacks-in-crash-reports in the document that crashed is true, and if the call stack was able to be recovered from the crashed document.

visibility_state Experimental

An enumerated value indicating whether the document is visible. This mirrors the value of the Document.visibilityState property. Possible values are:

visible

The document content is at least partially visible.

hidden

The document content is completely hidden.

Description

Crash reports containing arbitrary information can be sent to a server endpoint using the Reporting API . This is useful because we can store detailed diagnostic information throughout the lifetime of an application and use the reports to debug crashes more effectively.

The diagnostic information is stored in a special key-value store that can be manipulated using the document's CrashReportContext object. This is accessed via the Window.crashReport property.

When the browser crashes, the information stored in the key-value store is added to a CrashReport and sent to a reporting server. The reporting server endpoint and its mapping to a particular URL are set using the Reporting-Endpoints header.

  • If a crash-reporting server endpoint is defined, crash reports are delivered there. For example:
    http
    Reporting-Endpoints: crash-reporting="https://example.com/reports"
    
  • If a crash-reporting endpoint is not defined, but a default reporting server endpoint is defined, crash reports are delivered there. For example:
    http
    Reporting-Endpoints: default="https://example.com/reports"
    
  • If neither endpoint is defined, crash reports are not delivered.

Examples

Sending a report to a reporting endpoint

Configuring a web page to send a crash report requires that you define a reporting server endpoint using the Reporting-Endpoints header, for example https://example.com/reports, as described earlier.

A typical report structure is as follows:

json
{
  "age": 27,
  "type": "crash",
  "url": "https://example.com/",
  "user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
  "body": {
    "sourceFile": "https://example.com/",
    "reason": "unresponsive",
    "stack": "SomeError: ... at ...",
    "is_top_level": true,
    "visibility_state": "visible",
    "crash_report_api": {
      "crash_data_1": "0001",
      "crash_data_2": "0002"
    }
  }
}

The report will be sent as a JSON object in a POST request to the endpoint whenever the browser crashes.

Specifications

This feature does not appear to be defined in any specification.

Browser compatibility

See also