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

Does This Work With Web Workers? #5

Open
mshaw-siouxsteel opened this issue Apr 24, 2023 · 2 comments
Open

Does This Work With Web Workers? #5

mshaw-siouxsteel opened this issue Apr 24, 2023 · 2 comments

Comments

@mshaw-siouxsteel
Copy link

I'm attempting to debug an issue I have on an iPad regarding OPFS Web Workers, but I'm noticing that the Inline Console isn't getting any of the console.log() messages that I'm sending within my Web Worker. I've verified that I am sending and receiving messages to and from the Web Worker via other console.log() messages, and tested with having the first line of the onmessage within my worker be a console.log() as well.

Is there something I can do to enable logging from Web Workers or does this not have that kind of capability yet?

Thanks in advance!

@rwblackburn
Copy link
Owner

Hi @mshaw-siouxsteel - Sorry for the slow response.

I've never tested this within a web worker. I'm not terribly familiar with web workers, but my suspicion is the modifications we make to the things like window.onerror and window.onmessage in the main browser thread don't get carried over to the web worker threads?

@aarondill
Copy link
Collaborator

UNTESTED:

I think you would have to import the script with self.importScripts("inline-console.min.js").
Changes to the window global scope don’t affect worker scopes.

Additionally, and more importantly, you can’t update the DOM from a worker, so the script would have to use ‘postMessage’ to communicate with the main thread and update the visual console.

Having investigated this, I don’t believe there’s any way to modify the global scope of a Worker thread, so in its current implementation, it’s not possible to implement this. Perhaps if the inline-console script exported a function to setup (would global trap the defining scope?, is there anyway to do this without eval?), but not right now.

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

3 participants