keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Admin UI continually compiling

Open MadeByMike opened this issue 1 year ago • 24 comments

On a Linux\WSL machine start a new project following the quick start guide: https://keystonejs.com/docs/walkthroughs/getting-started-with-create-keystone-app#quick-start

Run yarn dev

It should compile once, then as required by Next while editing code and browsing.

  • Confirmed it is working correctly on Windows.
  • Confirmed it's not happening for prod builds.
  • It might be happening for CI running in production.
  • I assume developers have tested this on Mac.
  • Confirmed it to be the AdminUI and not a NextJS problem.

Linux:

image

Windows:

image

Next version: v.12.3.0

MadeByMike avatar Sep 09 '22 03:09 MadeByMike

Can confirm, having the same issue with a vanilla keystonekjs project. Running on manjaro with node 16.13.1 and 14.16.0.

cyanonoob avatar Sep 09 '22 10:09 cyanonoob

Can't reproduce this in my own Linux environment. I'll need to check with [email protected] :eyes:

dcousens avatar Sep 09 '22 11:09 dcousens

Can also confirm. Am getting a console warning for the <head> element appearing inside a <div>:

Warning: validateDOMNesting(...): <head> cannot appear as a child of <div>.
    at head
    at div
    at SigninContainer (webpack-internal:///../../node_modules/@keystone-6/auth/dist/useFromRedirect-cd014bce.esm.js:17:5)
    at InitPage (webpack-internal:///../../node_modules/@keystone-6/auth/pages/InitPage/dist/keystone-6-auth-pages-InitPage.esm.js:261:5)
    at ErrorBoundary (webpack-internal:///../../node_modules/@keystone-6/core/dist/Errors-07329dd1.esm.js:20:5)
    at DrawerProvider (webpack-internal:///../../node_modules/@keystone-ui/modals/dist/keystone-ui-modals.esm.js:54:5)
    at ToastProvider (webpack-internal:///../../node_modules/@keystone-ui/toast/dist/keystone-ui-toast.esm.js:41:5)
    at InternalKeystoneProvider (webpack-internal:///../../node_modules/@keystone-6/core/admin-ui/context/dist/keystone-6-core-admin-ui-context.esm.js:343:5)
    at ApolloProvider (webpack-internal:///../../node_modules/@apollo/client/react/context/ApolloProvider.js:12:21)
    at KeystoneProvider (webpack-internal:///../../node_modules/@keystone-6/core/admin-ui/context/dist/keystone-6-core-admin-ui-context.esm.js:394:14)
    at Core (webpack-internal:///../../node_modules/@keystone-ui/core/dist/keystone-ui-core.esm.js:1308:5)
    at eval (webpack-internal:///../../node_modules/@keystone-6/core/___internal-do-not-use-will-break-in-patch/admin-ui/pages/App/dist/keystone-6-core-___internal-do-not-use-will-break-in-patch-admin-ui-pages-App.esm.js:83:5)
    at ErrorBoundary (webpack-internal:///../../node_modules/next/dist/compiled/@next/react-dev-overlay/dist/client.js:8:20742)
    at ReactDevOverlay (webpack-internal:///../../node_modules/next/dist/compiled/@next/react-dev-overlay/dist/client.js:8:23635)
    at Container (webpack-internal:///../../node_modules/next/dist/client/index.js:70:9)
    at AppContainer (webpack-internal:///../../node_modules/next/dist/client/index.js:215:26)
    at Root (webpack-internal:///../../node_modules/next/dist/client/index.js:406:27)

Running MacOS Ventura

limegorilla avatar Sep 09 '22 14:09 limegorilla

This worked for me: Go to line 25 in auth.ts and change the sessionSecret to something else than the provided one. Not sure if it is related, but it stopped giving me compiled loop.

christianpedersen avatar Sep 09 '22 17:09 christianpedersen

This worked for me: Go to line 25 in auth.ts and change the sessionSecret to something else than the provided one. Not sure if it is related, but it stopped giving me compiled loop.

Didn't seem to work for me.

I also ran into an endless loop after simply running yarn create keystone-app keystone-test and then yarn dev in the new dir.

I initially got 4.0.0 of @keystone-6/auth e.g., but even after upgrading to the latest versions, still the same problem.

jschuur avatar Sep 09 '22 19:09 jschuur

I am also facing the same issue in macOS. I tried running the task-manager example too from the repository even in that code the issue persist.

FYI, this is happening in dev environment i tried building the production environment and the compiling issue went away.

Faiyyaz avatar Sep 10 '22 08:09 Faiyyaz

Is it possible that the autobuilder in dev mode is watching something get compiled, inadvertently triggering itself again?

cyanonoob avatar Sep 10 '22 10:09 cyanonoob

This worked for me: Go to line 25 in auth.ts and change the sessionSecret to something else than the provided one. Not sure if it is related, but it stopped giving me compiled loop.

Did not help . Facing same issue

Shpackk avatar Sep 10 '22 23:09 Shpackk

For those having problems, can you try changing your next version to [email protected]? This problem should be resolved with our recent switch to esbuild but that is not released yet; and in the interim, reverting to the previous version of next should help.

Please reply back if that works for you :pray:

dcousens avatar Sep 11 '22 04:09 dcousens

For those having problems, can you try changing your next version to [email protected]? This problem should be resolved with our recent switch to esbuild but that is not released yet; and in the interim, reverting to the previous version of next should help.

Please reply back if that works for you 🙏

Facing the same issue but only when adding keystone to a turborepo. I tried with version "[email protected]" but no luck. Any way to try out with esbuild on main branch?

ethras avatar Sep 11 '22 05:09 ethras

For those having problems, can you try changing your next version to [email protected]?

Edit: Using resolutions as described below fixed it in yarn for me too.

jschuur avatar Sep 11 '22 07:09 jschuur

After trying:

{ "name": "keystone-app", "version": "1.0.1", "private": true, "scripts": { "dev": "keystone dev", "start": "keystone start", "build": "keystone build", "postinstall": "keystone postinstall" }, "dependencies": { "@keystone-6/auth": "^4.0.0", "@keystone-6/core": "^2.1.0", "@keystone-6/fields-document": "^4.0.0", "typescript": "^4.7.4" }, "engines": { "node": "^14.15 || ^16.13" }, "overrides": { "next": "12.2.4" } }

I still have the same issue, also with trying rm -rf ./node_modules; yarn; yarn dev;

Edit: also tried with most recent releases of all packages, to no avail.

cyanonoob avatar Sep 11 '22 08:09 cyanonoob

Changing the next version to 12.2.4 using yarn resolutions fixes this issue.

Add this to your package.json. Note: resolutions will only work with yarn.

"resolutions": {
  "next": "12.2.4"
}

flexdinesh avatar Sep 12 '22 01:09 flexdinesh

Can confirm that running yarn add [email protected] then adding:

"resolutions": {
  "next": "12.2.4"
}

to the package.json seems to have worked for me.

MadeByMike avatar Sep 12 '22 01:09 MadeByMike

We've been seeing this issue for a while but as we weren't doing a lot of development on keystone itself we've been running a built (i.e. non-dev) version. When we run npm run dev it has this problem. It's been around for a while but we figured it was because we're running behind on upgrading keystone. We are on version 1.1.1 of keystone and are about to try to update. I can see locally I had nextjs version 12.1.6 with this issue.

We're also using npm so looks like the resolutions fix won't work for us.

We'll update keystone and see how we go, but did just want to add that we've been seeing the infinite compiling for quite a while now.

jordie23 avatar Sep 12 '22 01:09 jordie23

For people using npm, run npm install [email protected] then adding:

"overrides": {
  "next": "12.2.4"
}

to package.json worked for me.

yowlonglee avatar Sep 12 '22 03:09 yowlonglee

For yarn users

See @MadeByMike's comment

For npm users

If you are using npm, you will need to install graphql@^15.8.0 too. You may not need the overrides; but npm might opt to ignore you depending on how it resolves the dependencies.

See below for a dump of a log where I was able to reproduce this problem; and the steps I took to resolve it. (tl;dr, use npm install [email protected] graphql@^15.8.0 to get started with npm create keystone-app until https://github.com/keystonejs/create-keystone-app/pull/350 is merged).

$ npm create keystone-app keystone-test-npm

✨ You're about to generate a project using Keystone 6 packages.

✔ Installed dependencies with yarn.

🎉  Keystone created a starter project in: keystone-test-npm

  To launch your app, run:

  - cd keystone-test-npm
  - yarn dev

  Next steps:

  - Read keystone-test-npm/README.md for additional getting started details.
  - Edit keystone-test-npm/keystone.ts to customize your app.
  - Open the Admin UI (​http://localhost:3000​)
  - Open the Graphql API (​http://localhost:3000/api/graphql​)
  - Read the docs (​https://next.keystonejs.com​)
  - Star Keystone on GitHub (​https://github.com/keystonejs/keystone​)
$ cd keystone-test-npm/
$ npm run dev

> [email protected] dev
> keystone dev

✨ Starting Keystone
⭐️ Dev Server Starting on http://localhost:3000
⭐️ GraphQL API Starting on http://localhost:3000/api/graphql
✨ Generating GraphQL and Prisma schemas
✨ sqlite database "keystone.db" created at file:./keystone.db
✨ Your database is now in sync with your schema. Done in 387ms
✨ Connecting to the database
✨ Creating server
✅ GraphQL API ready
✨ Generating Admin UI code
✨ Preparing Admin UI app
event - compiled client and server successfully in 5.3s (1457 modules)
✅ Admin UI ready
wait  - compiling /api/__keystone_api_build (client and server)...
event - compiled successfully in 94 ms (199 modules)
wait  - compiling...
event - compiled client and server successfully in 201 ms (1474 modules)
wait  - compiling...
event - compiled client and server successfully in 183 ms (1474 modules)
wait  - compiling...
event - compiled client and server successfully in 158 ms (1474 modules)
wait  - compiling...
event - compiled client and server successfully in 136 ms (1474 modules)
wait  - compiling...
event - compiled client and server successfully in 132 ms (1474 modules)
wait  - compiling...
event - compiled client and server successfully in 119 ms (1474 modules)
^C
$ npm install [email protected]

added 3 packages, removed 1 package, changed 8 packages, and audited 925 packages in 7s
... omitted
$ npm run dev

> [email protected] dev
> keystone dev

✨ Starting Keystone
⭐️ Dev Server Starting on http://localhost:3000
⭐️ GraphQL API Starting on http://localhost:3000/api/graphql
Error: Cannot use GraphQLInputObjectType "{ name: "IDFilter", description: undefined, extensions: {}, astNode: undefined, extensionASTNodes: [], _fields: [function bound defineInputFieldMap] }" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
    at ... omitted
$ npm install graphql@^15.8.0
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/graphql
npm WARN   graphql@"^15.8.0" from the root project
npm WARN   34 more (@apollo/client, @apollo/utils.dropunuseddefinitions, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer graphql@"^16.3.0" from [email protected]
npm WARN node_modules/graphql-upload
npm WARN   graphql-upload@"^15.0.2" from @keystone-6/[email protected]
npm WARN   node_modules/@keystone-6/core
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/graphql
npm WARN   peer graphql@"^16.3.0" from [email protected]
npm WARN   node_modules/graphql-upload
npm WARN     graphql-upload@"^15.0.2" from @keystone-6/[email protected]
npm WARN     node_modules/@keystone-6/core

removed 3 packages, changed 1 package, and audited 922 packages in 3s

... omitted
$ npm run dev

> [email protected] dev
> keystone dev

✨ Starting Keystone
⭐️ Dev Server Starting on http://localhost:3000
⭐️ GraphQL API Starting on http://localhost:3000/api/graphql
✨ Generating GraphQL and Prisma schemas
✨ The database is already in sync with the Prisma schema.
✨ Connecting to the database
✨ Creating server
✅ GraphQL API ready
✨ Generating Admin UI code
✨ Preparing Admin UI app
event - compiled client and server successfully in 5.3s (1456 modules)
✅ Admin UI ready
wait  - compiling /api/__keystone_api_build...
event - compiled successfully in 102 ms (199 modules)

dcousens avatar Sep 12 '22 05:09 dcousens

Can confirm this works with next 12.2.4, can also confirm to have learned to use "resolutions" instead of "overrides" with yarn. Double thanks!

cyanonoob avatar Sep 13 '22 11:09 cyanonoob

I needed to delete node_modules/ and then reinstall packages with yarn after doing yarn add [email protected] and adding

"resolutions": {
  "next": "12.2.4"
}

to package.json.

pvaladez avatar Sep 14 '22 17:09 pvaladez

Would be great if someone could notify us here, when it's time to remove the "resolutions" from our package.json.

linus-ha avatar Sep 14 '22 17:09 linus-ha

@linus-ha you can't remove things from package.json only add ...forever 😜

MadeByMike avatar Sep 14 '22 23:09 MadeByMike

@linus-ha my intention is to leave this issue open and pinned until the next major release which will resolve these problems :blue_heart: - I will happily notify this thread when I close

dcousens avatar Sep 15 '22 00:09 dcousens

~Any ideas on how to work around this when running inside a yarn monorepo? "resolutions" doesn't seem to work (at either the packages/* level or the monorepo root), I think due to this bug: https://github.com/yarnpkg/yarn/issues/5039~

~Is there a known previous version I can downgrade to until this can be resolved here?~

And of course seconds after I leave this comment I realized my mistake, I hadn't specifically added "next": "12.2.4" to my dependencies directly. My package-level package.json now looks like this:

...
  "dependencies": {
    "@keystone-6/auth": "^4.0.0",
    "@keystone-6/core": "^2.1.0",
    "@keystone-6/fields-document": "^4.0.0",
    "dotenv": "^16.0.2",
+   "next": "12.2.4",
    "typescript": "^4.7.4"
  },
  "resolutions": {
    "next": "12.2.4"
  },
...

and my root-level package.json like this:

...
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.31.0",
    "@typescript-eslint/parser": "^5.31.0",
    "@typescript-eslint/utils": "^5.37.0",
    "eslint": "^8.20.0",
    "lerna": "^5.3.0",
    "prettier": "^2.7.1",
    "typescript": "^4.7.4"
  },
  "resolutions": {
    "next": "12.2.4"
  },
...

And the issue seems to have gone away 😅

christiannaths avatar Sep 16 '22 15:09 christiannaths

Changing the next version to 12.2.4 using yarn resolutions fixes this issue.

Add this to your package.json. Note: resolutions will only work with yarn.

"resolutions": {
  "next": "12.2.4"
}

This worked for me, thanks :)

naveenmatt avatar Sep 18 '22 06:09 naveenmatt

This has been resolved with the newest major release :package:.

Please don't forget to remove your resolutions or overrides when upgrading. Thanks for hanging in there everyone! :pray:

dcousens avatar Oct 19 '22 00:10 dcousens