anvilco / spectaql

Autogenerate static GraphQL API documentation
https://useanvil.com/docs/api/graphql/reference/
MIT License
1.11k stars 116 forks source link

Errors after official release of cheerio v.1.0.0 #986

Closed lisberPontes closed 2 months ago

lisberPontes commented 2 months ago

Hi there,

We're currently using spectaql 1.5.6 (however, we could see the very same error using the latest version of spectaql) which runs in our build pipeline everyday. We've been building for about 2 years now.

We noticed yesterday and error when using:

spectaql ../our-local-spectaql.yml -t html

But yesterday, we noticed the following error:

`#10 35.55 Running "compile-handlebars:compile" (compile-handlebars) task

10 35.66 Task error: [TypeError: Cannot read properties of undefined (reading 'load')

10 35.66 at markdown (/LOCAL-PATH/node_modules/spectaql/dist/lib/common.js:150:30)

10 35.66 at Object.module.exports (/LOCAL-PATH/node_modules/spectaql/dist/themes/default/helpers/md.js:19:35)

10 35.66 at Object.wrapper (/LOCAL-PATH/node_modules/handlebars/dist/cjs/handlebars/internal/wrapHelper.js:15:19)

10 35.66 at Object.eval (:21:94)

10 35.66 at main (/LOCAL-PATH/node_modules/handlebars/dist/cjs/handlebars/runtime.js:208:32)

10 35.66 at Object.ret (/LOCAL-PATH/node_modules/handlebars/dist/cjs/handlebars/runtime.js:212:12)

10 35.66 at Object.ret [as graphql/_query-or-mutation-or-subscription] (/LOCAL-PATH/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:519:21)

10 35.66 at Object.invokePartialWrapper [as invokePartial] (/LOCAL-PATH/node_modules/handlebars/dist/cjs/handlebars/runtime.js:88:46)`

Looking at -> /spectaql/dist/lib/common.js:150:30

which by browsing the code:

Source: https://www.npmjs.com/package/spectaql/v/1.5.6?activeTab=code image

We noticed there was this called to let $ = _cheerio.default.load('<root>' + html + '</root>')('root');

We also compared the build (green) from 2 days ago with the red build (from yesterday), and we noticed: image

After locking the dependency to: npm install -s cheerio@1.0.0-rc.12

We could start to build green again.

Questions/Doubts:

  1. Is it possible from your side to lock version dependencies ?
  2. Can the current code (a new version of spectaql) be adapted so we can avoid this error ?

Thanks in advance!

tstocker-black-cape commented 2 months ago

Our app is having the same issue. We're installing cheerio@1.0.0-rc.12 as a workaround.

newhouse commented 2 months ago

Duplicate of https://github.com/anvilco/spectaql/issues/979

newhouse commented 2 months ago

@lisberPontes @tstocker-black-cape

This came to my attention yesterday in a separate issue, and it should be fixed now in main and spectaql@3.0.2 via https://github.com/anvilco/spectaql/pull/980

Can you please confirm?

You should not have to peg or install your own version of cheerio, and you should be able to remove that if you did.

Closing for now.

newhouse commented 2 months ago

Eh @lisberPontes I noticed that you are on 1.x, and my previous fix was for 3.x. I have gone ahead and also added a fix for you in spectaql@1.5.12, but this will be the last time that I touch 1.x. It has been "left in the dust" and you should upgrade to spectaql 3.

lisberPontes commented 2 months ago

Hi @newhouse,

Thanks for upgrading 1.x. Based on your comment, we've decided to bump up our version of spectaql to 3.0.2. I've tested and it's working just fine.

Thanks for the fix. It didn't feel right to peg the cheerio dependency in our end.