Description
Describe the bug
Using v3.1.1 and calling importScripts() in a worker to load socket.io.js results in a NetworkError, such as the following:
Use of importScripts() works fine with v2.
To Reproduce
The attached zip file contains 4 files: v2.html, v2.js, along with v3.html, v3.js ... but they are short:
v2.html:
<html>
<body>
<script>
let v2 = new Worker("v2.js");
</script>
</body>
</html>
v2.js:
importScripts("https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js");
v3.html:
<html>
<body>
<script>
let v3 = new Worker("v3.js");
</script>
</body>
</html>
v3.js:
importScripts("https://cdn.socket.io/3.1.1/socket.io.js");
These two test cases use CDN files for the sake of simplicity. I am not using CDN files in my project, but get the same result.
To see the correct behavior (no error), load v2.html. To see the error in the JavaScript console, load v3.html.
According to https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts, the Network error is indicates:
Expected behavior
I expect importScripts() to load socket.io.js successfully.
Platform:
- Device: Macbook Pro
- OS: 10.15.7