Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Loading ipfs-js bundle in worker fails with ReferenceError: window is not defined #2349

Closed
Gozala opened this issue Aug 13, 2019 · 1 comment · Fixed by ipfs/aegir#408
Closed
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/in-progress In progress

Comments

@Gozala
Copy link
Contributor

Gozala commented Aug 13, 2019

Current bundles assume window global which is not true in worker context:

See https://unpkg.com/browse/[email protected]/dist/index.js#L10

@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) exp/novice Someone with a little familiarity can pick up status/in-progress In progress P1 High: Likely tackled by core team if no one steps up labels Aug 14, 2019
@icidasset
Copy link
Contributor

Workaround:

self.window = self

achingbrain added a commit to ipfs/aegir that referenced this issue Oct 26, 2020
`globalObject` is `"window"` by default which is not available in web workers. Using `"self"` allows the bundle to work in both environments.

resolves ipfs/js-ipfs#2349

Co-authored-by: David Dias <[email protected]>
Co-authored-by: achingbrain <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/in-progress In progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants