Skip to content

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
mainfrom
fix_apollo_worker_document
Open

Avoid accessing global document in webworker to fix https://github.com/GMOD/jbrowse-components/issues/5582#803
cmdcolin wants to merge 1 commit into
mainfrom
fix_apollo_worker_document

Conversation

@cmdcolin

Copy link
Copy Markdown

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

…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.
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

Successfully merging this pull request may close these issues.

1 participant