Open chrisvanmook opened 1 month ago
Hey @chrisvanmook , the getPayloadHMR arg typing is a bit too wide here. It is not intended to change options other than the config and the importMap. We'll be trimming up this type to avoid any confusion here.
Hey @chrisvanmook , the getPayloadHMR arg typing is a bit too wide here. It is not intended to change options other than the config and the importMap. We'll be trimming up this type to avoid any confusion here.
Ah that makes sense! However, how should I be able to set these initial options with NextJS, since we only have the RootLayout component that initiates payload?
Ideally, most of these values should be able to be set in the config itself. I'll be investigating this, since it doesn't look like the logger options can be set in the config currently.
Hi @denolfe, do you perhaps have any updates on this?
Link to reproduction
No response
Payload Version
3.0.0-beta.90
Node Version
v20.11.1
Next.js Version
15.0.0-canary.104
Describe the Bug
When passing options to
getPayloadHMR
, for example in a server action, it returns a payload instance without those options set. I think the issue here is becauseRootLayout
is responsible initiating a payload instance, but we can only pass the config to the props (and thus RootLayout will use the defaultInitOptions
to create a payload instance). So when callinggetPayloadHMR
, I think it returns a cached version of this instance.I think there are some possible solutions here:
initOptions
prop to RootLayout, like<RootLayout importMap={importMap} config={configPromise} initOptions={{ loggerOptions: { level: process.env.LOG_LEVEL ?? 'debug' } }}>
. Then perhaps add a warning when trying to callgetPayloadHMR
with options if a cached version is found?getPayloadHMR
overrides the initOptions. Problem here is we still can't set the options initially...Reproduction Steps
Create a server component with an action like so:
Adapters and Plugins
db-postgres