Skip to content

Statements no longer sent when browser (Chrome) closed #166

Open

Description

@danielghost

Now that Chrome has finally deprecated synchronous XHR in Chrome 80, any statements triggered when the browser closes will be lost, as asynchronous calls will not be resolved in time. This is important if using terminated type statements, and is actually a requirement if following the cmi5 profile.

Not sure whether other browsers will follow, but should the wrapper look to use the Beacon API (with a Polyfill for IE11) to handle the communication?

Activity

  1. danielghost commented on May 12, 2020

    @danielghost
    Author

    Doesn't look like the Beacon API can be used as you cannot customise the headers as required for xAPI. You can instead use the Fetch API with the keepalive flag. Where the Fetch API is not supported, e.g. IE11, the current XHR requests can still be used and sent synchronously for any statements sent when the browser is closed.

  2. added a commit that references this issue on Sep 30, 2020
  3. ysrn commented on Oct 11, 2021

    @ysrn

    It is possible to use the Beacon API here, by relying on the old IE fallback mechanism in the LRS ("Alternate Request Syntax"), which allows headers to be passed in the body of the request and the method to be passed in the query string, see https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#alt-request-syntax

    -EDIT-
    It looks like the Chrome folks finally half-fixed fetch's keepalive (https://bugs.chromium.org/p/chromium/issues/detail?id=810466), so that might work for some scenarios, but apparently not in real CORS scenarios requiring preflight, so Beacon it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions