#TypeError: Cannot call a class as a function (next-payload)

8 messages · Page 1 of 1 (latest)

muted tiger
#

Hello,

let me just say that developing with payload is awesome! Tried quite a few "cms"es and payload is so far the best to work with. I just got one issue at which I am stuck for several hours now actually.

I am getting this error on production build:
TypeError: Cannot call a class as a function

It goes away after I remove all the instances of getPayloadClient().

This is the whole error message:
TypeError: Cannot call a class as a function
at _class_call_check (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:91:15)
at new PgSelectQueryBuilder (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:40680:17)
at PgSelect._createSuperInternal (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:376:30)
at new PgSelect (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:40855:37)
at PgSelectBuilder.from (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:40660:111)
at E:\dev\metering-services\metering-website.next\server\chunks\6737.js:9129:40
at step (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:461:23)
at Object.next (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:402:20)
at asyncGeneratorStep (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:62:28)
at _next (E:\dev\metering-services\metering-website.next\server\chunks\6737.js:80:17)
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
digest: '1006470278'
}

Any idea what to do here?

EDIT: I should mention that I am working with next-payload. Heard that it's quite a stressful thing to develop on it, but the local api is must have at this point for me :D

gritty oakBOT
muted tiger
#

Alright, fixed it. No idea what and why it happend, but starting the admin first when I finished with building and then accessing the website fixed the issue. Annoying, but nothing horrible here.

Excited for payload in nextjs by default!

gritty oakBOT
solid zephyr
#

@muted tiger Hi mate how are you

#

are you using the next payload now?

muted tiger
#

No, not anymore :/ Migrated it to separate express server. Had too much trouble with it on production.

#

From what I experienced so far, I would wait untill the real nextjs integration is ready with next version of payload. I did the migration of my site in like 10 minutes from next to express. And it should be the same experience in the next payload release.