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

Crash: window is not defined #668

Open
Jack-Works opened this issue Jul 26, 2022 · 5 comments
Open

Crash: window is not defined #668

Jack-Works opened this issue Jul 26, 2022 · 5 comments

Comments

@Jack-Works
Copy link

image

image

There is some code in this library try to access window and crashes.

@ChaituVR
Copy link
Member

Hi @Jack-Works I can't reproduce it, can you plz share with us code / a sandbox to reproduce this? will take a look.

@Jack-Works
Copy link
Author

sorry I forgot to say, this is in a Web Worker, where window is not available.

@Jack-Works
Copy link
Author

image

worker.html

<script>
new Worker("./worker.js")
</script>

worker.js

import("https://cdn.jsdelivr.net/npm/@snapshot-labs/snapshot.js")

@ChaituVR
Copy link
Member

@Jack-Works Make sure to wrap your code with if (window.Worker) {
https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#worker_feature_detection

@Jack-Works
Copy link
Author

our environment support worker, and we need to run it in a worker. but this package bundles a outdated __await implementation that access window and crashes.

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

2 participants