-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Exception due to trying to access document from a worker #7222
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
Comments
Interesting, that should not be the case. But we do define
which means that if I think your first proposal is a good solution here, thanks, please open a PR with that if you can. |
Fixes #7222 In some situations, the window object may be defined in a worker context, for example if window is defined for a polyfill. In these cases, the worker would report ENVIRONMENT_IS_WEB true and attempt to access document.currentScript. This would cause the worker to crash. This PR inverts that check so that we check if we're a worker rather than web. This shouldn't cause any changes to functionality.
Hello, when i call is this the correct way? |
We are seeing an exception coming from shell.js because the worker accesses document.currentScript.
From src/shell.js#231
I've tested and at least in our environment, the worker has ENVIRONMENT_IS_WEB and ENVIRONMENT_IS_WORKER true. If this is always the case, the else clause is a no-op. I'm not completely familiar with this code but would suggest this becomes:
The other approach would be:
The code was introduced in #6894, maybe @kripken can provide some insight on the right approach. Let me know if you'd like me to open a PR.
The text was updated successfully, but these errors were encountered: