Avoid accessing global document in webworker to fix https://github.com/GMOD/jbrowse-components/issues/5582#803
Open
cmdcolin wants to merge 1 commit into
Open
Avoid accessing global document in webworker to fix https://github.com/GMOD/jbrowse-components/issues/5582#803cmdcolin wants to merge 1 commit into
cmdcolin wants to merge 1 commit into
Conversation
…rker context This module loads in jbrowse's RPC worker (all configured plugins load there unconditionally), where globalThis.document is undefined. The module-level canvas pattern setup assumed document always exists, just guarding the canvas.getContext result -- that worked while jbrowse's worker provided a stub document, but jbrowse removed that polyfill, so document.createElement now throws synchronously and crashes the whole plugin load via importScripts (surfaced by Chrome as a generic NetworkError, masking the real TypeError). Guard the document access itself instead; these patterns are main-thread-only rendering fills the worker never needs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We deleted the 'worker polyfill' as part of a fairly aggressive effort to 'simplify' things. it can cause breakages in cases like this where the apollo plugin globally created document.createElement from the worker. it might be good to fix on apollo side