[Webkit-unassigned] [Bug 198665] New: Race condition makes ESM modules to evaluate twice

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jun 7 10:11:38 PDT 2019


https://bugs.webkit.org/show_bug.cgi?id=198665

            Bug ID: 198665
           Summary: Race condition makes ESM modules to evaluate twice
           Product: WebKit
           Version: Safari 12
          Hardware: Macintosh
                OS: macOS 10.14
            Status: NEW
          Severity: Critical
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: manu.mtza at gmail.com

Created attachment 371592

  --> https://bugs.webkit.org/attachment.cgi?id=371592&action=review

Repo case

Looks like there is a race condition when loading ESM modules in Safari, that leads the same module.
When using dynamic import(), the same ES module is evaludated more than once.

Here's the simplest repo case that reproduces it:
https://github.com/manucorporat/webkit-esm-bug

- Server the repo with a HTTP server
- Open the Safari dev tools,
- Reload several times until you can see several "load" console logs

HTML
```

<body>
  <script type="module">
    import "/build/index.js";
  </script>
</body>
```

index.js
```
let a = 0;
console.log('load', a++);
function hello() {
  import('./chunk.js')
}
hello();
```

chunk.js
```
import "./index.js";
```

EXPECTED BEHAVIOUR:

Same as Chrome, or Firefox.
The `index.js` module should be evaluated only once. This is causing crashes in a production website: https://stenciljs.com/
And most likely any users of Stenciljs in iOS

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190607/7e609a08/attachment.html>


More information about the webkit-unassigned mailing list