Error deploying GraphQL in Sanity due to prism syntax highlighter using document in node.js context
14 replies
Last updated: Feb 5, 2021
Anyone ever run into this one?
Uncaught [ReferenceError: document is not defined]when deploying the graphql? It errors midway but still successfully deploys π€ (Just ran a sanity upgrade just in case, but still persists!)
Anyone ever run into this one? `Uncaught [ReferenceError: document is not defined]` yarn deploy:graphql yarn run v1.22.10 $ sanity graphql deploy --playground Dataset: production Tag: default β Checking for deployed API β Generating GraphQL schema β Validating GraphQL APIError: Uncaught [ReferenceError: document is not defined] βββββ[FULL ERROR IN THREAD]βββββ β Validating GraphQL API β Deploying GraphQL API GraphQL API deployed to: [myGraphQlPlaygroundUrlHere]
Jan 31, 2021, 4:14 PM
Uncaught [ReferenceError: document is not defined] at reportException (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:66:24) at innerInvokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:312:9) at invokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:251:3) at DocumentImpl._dispatch (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:205:11) at DocumentImpl.dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17) at dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:488:13) at /Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:493:11 at new Promise (<anonymous>) at onDOMContentLoad (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:491:14) at Object.check (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:76:23) ReferenceError: document is not defined at Object.highlightAll (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/prismjs/components/prism-core.js:530:23) at Document.highlightAutomaticallyCallback (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/prismjs/components/prism-core.js:1193:5) at innerInvokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:296:27) at invokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:251:3) at DocumentImpl._dispatch (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:205:11) at DocumentImpl.dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17) at dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:488:13) at /Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:493:11 at new Promise (<anonymous>) at onDOMContentLoad (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:491:14)
Jan 31, 2021, 4:15 PM
G
I've been getting this constantly ever since upgrading sanity this week. After incrementally adding bits to a brand new empty studio I found mine throwing this error when I included a few specific plugins.
The plugins themselves were still working and the gql redeployed correctly.
I upgraded an old build and started getting the same error. Very odd
The plugins themselves were still working and the gql redeployed correctly.
I upgraded an old build and started getting the same error. Very odd
Jan 31, 2021, 6:37 PM
Do you have any syntax highlighting plugin or code preview/input installed in your studio? It seems to be stemming from prism (a syntax highlighter) using
documentin a node.js context.
Jan 31, 2021, 9:48 PM
R
Espen Hovlandsdal
the only thing I've got installed is the sanity color input!Feb 1, 2021, 12:14 PM
R
Hm, looks like weβve got a common denominator then!
Feb 1, 2021, 10:37 PM
E
Rafael Derolez
Are you also using the "color-list" plugin, or a different one? There's several color plugins out thereFeb 1, 2021, 11:10 PM
K
Iβve got the same problem, and the same plugin.
Feb 2, 2021, 4:15 AM
E
That's good to know. I'll have a look and see if I can find the culprit π΅οΈββοΈ π
Feb 2, 2021, 4:20 AM
E
Found the culprit - https://github.com/sanity-io/sanity/pull/2279 Hoping to have a fix in a day or two
π
π
Feb 2, 2021, 5:49 AM
R
Espen Hovlandsdal
no I'm using "@sanity/color-input": "^2.1.4",actually
Feb 2, 2021, 8:30 AM
R
Awesome to see it fixed so quickly though, nice work βοΈ
Feb 2, 2021, 8:31 AM
E
Fixed in v2.3.3
Feb 4, 2021, 5:52 PM
K
π€
Feb 4, 2021, 5:53 PM
R
Nice one thanks
Espen Hovlandsdal
Feb 5, 2021, 10:04 AM
Sanityβ build remarkable experiences at scale
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.