scorm-again icon indicating copy to clipboard operation
scorm-again copied to clipboard

Synchronous XHR in page dismissal - iframe

Open gojevicmario opened this issue 2 years ago • 2 comments

I am using scorm-again to run courses generated from articulate rise. We are running them in iframe and once the user closes the iframe we get this error message.

DOMException: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'ApiURL/update': Synchronous XHR in page dismissal. See https://www.chromestatus.com/feature/4664843055398912 for more details.
    at n (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:25077)
    at g (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:5041)
    at w (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:5245)
    at Function.M.flush (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:5674)
    at o.value (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:25675)
    at o.value (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:32826)
    at o.value (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:14496)
    at o.value [as LMSFinish] (WebAppURL/_next/static/chunks/9.badbab7d92546a90cb17.js:1:29772)
    at SCORM_CallLMSFinish (WebAppURL/s3/001725d8-c170-438f-ba62-4bc5d56a0c29/scormdriver/scormdriver.js:640:172)
    at LMSStandardAPI.SCORM_Finish [as Finish] (WebAppURL/s3/001725d8-c170-438f-ba62-4bc5d56a0c29/scormdriver/scormdriver.js:435:251)
n @ 9.badbab7d92546a90cb17.js:1

I assume that the iframe closes before the lmsComitURL has time to send the final update request.

our settings look like this

{
        alwaysSendTotalTime: true,
        autocommit: true,
        autocommitSeconds: AUTOCOMMIT_SECONDS,
        logLevel: 1,
        lmsCommitUrl: `ApiURL/update`,
        mastery_override: true,
        selfReportSessionTime: true,
}

Do you have any ideas on how we could resolve this issue? Thank you

gojevicmario avatar Mar 14 '22 15:03 gojevicmario

There seems to be an undocumented option asyncCommit. For me, setting this to true, makes the error go away. But I don't know yet, if this introduces other problems.

Maybe this helps.

jdieckmannelm avatar May 31 '22 14:05 jdieckmannelm

@jdieckmannelm thanks for pointing that out! I didn't realize that I hadn't documented that setting. Yes, the asyncCommit setting was provided to avoid the synchronous commit calls being blocked upon page unload in Chrome. However, it's still not the most reliable solution, as Chrome is rather hostile towards code running while trying to close a window/tab.

jcputney avatar Jun 23 '22 02:06 jcputney