Closed Bug 1788532 Opened 2 years ago Closed 2 years ago

Getting `InternalError: module record has unexpected status` during synchronous XMLHttpRequests

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

RESOLVED FIXED
106 Branch
Tracking Status
firefox106 --- fixed

People

(Reporter: twisniewski, Assigned: jonco)

References

(Blocks 1 open bug, )

Details

Attachments

(2 files)

When navigating between the tabs at the top-left on https://anjunar.github.io/simplicity/expert/meta/overview, the console will sometimes show this stack trace:

Uncaught (in promise) InternalError: module record has unexpected status
    loader https://anjunar.github.io/simplicity/library/simplicity-core/processors/loader-processor.js:7
    get template https://anjunar.github.io/simplicity/documentation/expert/meta/overview.js line 7 > srcScript:12
    define https://anjunar.github.io/simplicity/library/simplicity-core/simplicity.js:31
    define https://anjunar.github.io/simplicity/library/simplicity-core/simplicity.js:177
    <anonymous> https://anjunar.github.io/simplicity/documentation/expert/meta/overview.js line 7 > srcScript:17
    loader https://anjunar.github.io/simplicity/library/simplicity-core/processors/loader-processor.js:7
    get template https://anjunar.github.io/simplicity/documentation/expert/index.js:25
    define https://anjunar.github.io/simplicity/library/simplicity-core/simplicity.js:31
    define https://anjunar.github.io/simplicity/library/simplicity-core/simplicity.js:177
    <anonymous> https://anjunar.github.io/simplicity/documentation/expert/index.js:29

It is failing on the send call of this synchronous XMLHttpRequest:

export function loader(url) {
    let request = new XMLHttpRequest();
    let newUrl = "./" + url;
    request.open("GET", newUrl, false)
    request.send(null)
    return request.response;
}

On a local build, I added some simple printf-logging and found that the erorr is thrown from InnerModuleLinking in Modules.cpp.

This makes me suspect that maybe the JS module code doesn't work well with synchronous XMLHttpRequests, but I'm not well-versed in the topic, so I decided to file a bug here to try to make sense of this.

(In reply to Thomas Wisniewski [:twisniewski] from comment #0)
Thanks for the bug report!

Reproduced. Doesn't seem to be related to bug 1787926 which landed yesterday.

Assignee: nobody → jcoppeard
Depends on: 1788882
Severity: -- → S3
Priority: -- → P2

@jonco, although bug 1788882 landed, I'm still seeing "InternalError: module record has unexpected status: Evaluating" on this website in a nightly build from today. Is that expected?

Flags: needinfo?(jcoppeard)

(In reply to Thomas Wisniewski [:twisniewski] from comment #2)

@jonco, although bug 1788882 landed, I'm still seeing "InternalError: module record has unexpected status: Evaluating" on this website in a nightly build from today. Is that expected?

Yes. That patch wasn't a fix for the underlying issue, it makes it so it doesn't crash the browser (in debug builds) and the error is detected sooner.

Flags: needinfo?(jcoppeard)

The looks like it's a longstanding issue with synchronous XHR and an example of bug 978757.

The problem is that synchronous XMLHttpRequest requests can spin the event loop
and cause us to process dynamic module loads (by calling
JS::FinishDynamicModuleImport) when we are already inside JS::ModuleEvaluate.
The module algorithms assume that they are not reentrant.

The patch changes dyammic module load processing to happen in the same way as
async script loads (of both classic scripts and modules), which are blocked
during sync XHR by Document::SuppressEventHandling calling
ScriptLoader::AddExecuteBlocker.

Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c0269cec57bb
Block dynamic module load processing during sync XHR r=smaug
https://hg.mozilla.org/integration/autoland/rev/8197913e2534
Add a test for the interaction between dynamic module loading and sync XRH r=smaug
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 106 Branch
See Also: → 1796666
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: