payload icon indicating copy to clipboard operation
payload copied to clipboard

Timeout after update to 3.0.0-beta.76 and next 15.0.0-canary.104

Open mednet-ecrep opened this issue 2 years ago • 16 comments

Link to reproduction

No response

Payload Version

3.0.0-beta.76

Node Version

v20.9.0

Next.js Version

15.0.0-canary.104

Describe the Bug

After updating from payload beta 74 and next canary 86 to Payload beta 76 and Next Canary 104, the admin panel can no longer be accessed and results in a timeout. The login page does not render.

Before the update, everything was working perfectly.

The problem occurs only in a production build. Everything continues to work fine in development mode.

Reproduction Steps

Update to the payload 3.0.0-beta.76 and next canary 104. Create a and run a production build. Then try to access the payload login page.

Adapters and Plugins

db-mongodb, storage-vercel-blob, form-builder, nested-docs, seo, live-previewrichtext-lexical,

mednet-ecrep avatar Aug 08 '24 06:08 mednet-ecrep

Encountering the same problem, runtime error:

TypeError: Cannot read properties of undefined (reading 'query')
    at tV (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:1420)
    at async Object.tz [as findGlobal] (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:4292)
    at async l (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:266:102390)
    at async f (/home/dovchik/source/payload-play/.next/server/chunks/6310.js:1:16628) {
  digest: '3855654830'
}
TypeError: Cannot read properties of undefined (reading 'query')
    at tV (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:1420)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
    at async Object.tz [as findGlobal] (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:4292)
    at async l (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:266:102390)
    at async f (/home/dovchik/source/payload-play/.next/server/chunks/6310.js:1:16628) {
  digest: '343576256'
}

Dovchik avatar Aug 08 '24 14:08 Dovchik

This might be the same issue: https://discord.com/channels/967097582721572934/1215659716538273832/1271103045908037672

Here is a reproduction of this issue: https://github.com/payloadcms/payload-3.0-demo/compare/main...remarcable:payload-3.0-demo:admin-panel-loading-repro?expand=1

The reason seems to be richText fields nested inside blocks.

remarcable avatar Aug 08 '24 14:08 remarcable

I just created another bug, which I will delete. Same error. Just upgraded from beta.36 though

jomapps avatar Aug 09 '24 21:08 jomapps

I got the same issue now, but when I downgrade the next.js version to 15.0.0-canary.77, it works fine again?? What's going on here?

vuquangpham avatar Aug 10 '24 10:08 vuquangpham

Hi all - we're seeing a similar issue:

On production builds only - i.e., pnpm build && pnpm start - the Payload admin app will not load if there is more than one collection with a richText field (they don't have to be nested in a block).

For example - we created test Foo and Bar collections - based on the built-in Lexical richtext editor and in each there are only two fields: title (text) and content as (richText).

Foo and Bar collections each have the following richtext field definition:

{ type: 'richText', name: 'richText', label: 'RichText', required: true, },

We can compile and load the admin dashboard if we load just the Foo collection or just the Bar collection - but not both. We can only load both along with the admin dashboard in development. :-(

In a production build - the request for the /admin URL remains stuck at 'pending' (with zero output - errors or other).

Here's a link to a reproducible repo - a fork of Demo 3 repo.

https://github.com/infonomic/payload-3.0-demo

pnpm install && pnpm build && pnpm start - should reproduce the problem. All that's changed is another collection with a richText field was added to payload.config.ts. Navigating to /admin will fail on 'pending' indefinitely.

Hope this helps.

58bits avatar Aug 11 '24 08:08 58bits

For us, everything works fine on payload 3.0.0-beta.77 and (!) next 15.0.0-canary.87. So it seems like an issue with the next >15.0.0-canary.87 (or newer).

BohdanK-W32 avatar Aug 13 '24 12:08 BohdanK-W32

Just updated to v3.0.0-beta.78 and still getting a timeout when loading the admin login page.

mednet-ecrep avatar Aug 13 '24 14:08 mednet-ecrep

For us, everything works fine on payload 3.0.0-beta.77 and (!) next 15.0.0-canary.87. So it seems like an issue with the next >15.0.0-canary.87 (or newer).

I can confirm. The admin panel works for us with 3.0.0-beta.78 and next 15.0.0-canary.87. Won’t work with next versions higher than that. We also have multiple richText fields in various places.

robinscholz avatar Aug 13 '24 15:08 robinscholz

I recommend either staying on an older payload & Next.js version, or attaching an editor to every richtext field causing this issue for now. This issue has been introduced by the recent Next.js update - if objects with same references are passed down as props to 2+ components, Next.js started hanging like this. For richText fields, this issue can appear because they reference the same root richText editor.

We will fix this once we're done with https://github.com/payloadcms/payload/pull/7620

AlessioGr avatar Aug 13 '24 15:08 AlessioGr

@AlessioGr attaching an editor to every richtText field does not seem to work for us. Tried both:

Tried invoking the editor separately and passing it:

import { lexicalEditor } from '@payloadcms/richtext-lexical'
import type { RichTextField } from 'payload'

// Hotfix: https://github.com/payloadcms/payload/issues/7578#issuecomment-2286571529
export function contentField(editor: ReturnType<typeof lexicalEditor>) {
  const contentField: RichTextField = {
    name: 'content',
    type: 'richText',
    editor: editor,
  }

  return contentField
}

And tried setting it manually:

import { lexicalEditor } from '@payloadcms/richtext-lexical'
import type { RichTextField } from 'payload'

const editor = lexicalEditor()

export const contentField: RichTextField = {
  name: 'content',
  type: 'richText',
  editor: editor,
}

Running 3.0.0-beta.78 and next 15.0.0-canary.104

robinscholz avatar Aug 13 '24 16:08 robinscholz

@robinscholz make sure you're using a uniquely initialized editor for every field, without sharing the editor object between fields

AlessioGr avatar Aug 13 '24 18:08 AlessioGr

Fixed by https://github.com/payloadcms/payload/pull/7620

AlessioGr avatar Aug 13 '24 20:08 AlessioGr

Encountering the same problem, runtime error:

TypeError: Cannot read properties of undefined (reading 'query')
    at tV (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:1420)
    at async Object.tz [as findGlobal] (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:4292)
    at async l (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:266:102390)
    at async f (/home/dovchik/source/payload-play/.next/server/chunks/6310.js:1:16628) {
  digest: '3855654830'
}
TypeError: Cannot read properties of undefined (reading 'query')
    at tV (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:1420)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
    at async Object.tz [as findGlobal] (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:193:4292)
    at async l (/home/dovchik/source/payload-play/.next/server/chunks/8447.js:266:102390)
    at async f (/home/dovchik/source/payload-play/.next/server/chunks/6310.js:1:16628) {
  digest: '343576256'
}

@AlessioGr I'm still getting the same bunch of errors with build and start and admin panel not loading with [email protected] and [email protected] Also, I'm using postgres adapter

Dovchik avatar Aug 15 '24 11:08 Dovchik

Okay, that seems to be related to how I passed payload instance around Seems that getPayloadHMR in root level of a document was breaking it all

Dovchik avatar Aug 15 '24 11:08 Dovchik

It is still happening, running on next: 15.0.0-canary.128, payload: 3.0.0-beta.91, node: 20.9.0.

Only after dropping lexical (which was used in just one collection) did things start working again.

edtorba avatar Aug 26 '24 21:08 edtorba

This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.

github-actions[bot] avatar Sep 06 '24 20:09 github-actions[bot]