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

Using Resource Override to override a JavaScript file that is loaded as a SharedWorker doesn't work #57

Open
TomF-NVM opened this issue Aug 3, 2022 · 0 comments

Comments

@TomF-NVM
Copy link

TomF-NVM commented Aug 3, 2022

Here is some sample code creating a SharedWorker:
`
const myWorker = new SharedWorker('worker.js')
myWorker.port.start()
myWorker.port.onmessage = function (e) {
console.log('Message received from worker', e)
}

window.setTimeout(() => {
console.log('Posting message to worker')
myWorker.port.postMessage('hello')
}, 3000)
`

If I place the worker file (worker.js) on the same server as the html that contains the above code, then I see console logs for messages going to a from the worker.
However, if I host the worker locally with a resource override pointing at it, then creating the SharedWorker fails silently and the network tab shows the request as stalled with a status of (pending).

If I simply load the shared worker js file in a browser tab then Resource Override serves it fine, so it's not that RO is unable to serve the file to the browser. It just seems unable to serve the file for the purpose of being used as a Shared Worker.

I am using url -> url mapping with http-server -c-1 --cors. The requests are not shown in the http-server logs, so appear to be blocked in the browser.

Example code:
example.zip

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

1 participant