Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danielghost opened this issue Apr 6, 2020 · 2 comments
Open

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

danielghost opened this issue Apr 6, 2020 · 2 comments

Comments

@danielghost
Copy link

danielghost commented Apr 6, 2020

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?

@danielghost
Copy link
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.

danielghost added a commit to cgkineo/adapt-xAPI that referenced this issue Jul 21, 2020
…succession to the same object, to persist the older data, even if the calls where fired in the correct order. State calls are now queued, so it is no longer possible for the LRS to save the states in the wrong order due to the time it takes to execute the asynchronous requests. This also required a move from the XHR requests used in the ADLWrapper as these do not work with the callback functionality used with Async.queue. Moved to using the Fetch API with a modified polyfill for browsers which don't support the API or the keepalive attribute, to resolve adlnet/xAPIWrapper#166.
bbeversdorf pushed a commit to bbeversdorf/xAPIWrapper that referenced this issue Sep 30, 2020
@ysrn
Copy link

ysrn commented Oct 11, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants