Skip to content

Admin panel keeps the previous client config / field schema map after a config reload in dev (new field missing from the form) #19151

Open

Description

@RafalFilipek

Describe the Bug

In next dev, after editing the Payload config (for example adding a field to a collection), the edit view sometimes keeps rendering the form from the previous config until the dev server is restarted. The new field does not show in the form, and the server log can show:

Cannot use 'in' operator to search for 'hidden' in undefined

The cause is the module-level caches in @payloadcms/ui:

  • packages/ui/src/utilities/getClientConfig.ts (client config per language)
  • packages/ui/src/utilities/getSchemaMap.ts (field schema map per collection / global / widget)
  • packages/ui/src/utilities/getClientSchemaMap.ts (client field schema map per language and entity)

They are not tied to the config they were built from. They are only invalidated through the global flags (global._payload_doNotCacheClientConfig, _payload_doNotCacheSchemaMap, _payload_doNotCacheClientSchemaMap) that reload() sets once. After a reload, a request that is still rendering with the previous config object can be the first to reach these functions: it consumes the flag and fills the cache with maps built from the old config. Every later request, which already passes the new config, then gets the stale cached entry. The form for the new field gets a client field map without that field, so the field is missing (and lookups such as 'hidden' in field hit undefined).

A related detail: reload() replaces global._payload_clientConfigs / _payload_schemaMap / _payload_clientSchemaMap, but the modules hold their own reference read at import time, so that reset does not reach them either; only the flags do.

Link to the code that reproduces this issue

https://github.com/RafalFilipek/payload/tree/fix/ui-client-config-cache-per-config

(The branch contains the fix and unit tests in packages/ui/src/utilities/*.spec.ts. The new tests fail on main: they call each function with config A and then with a different config B and get A's result back.)

Reproduction Steps

  1. Start any project (e.g. the _community test config) with next dev and open a document's edit view in the admin panel.
  2. Add a new field to that collection in the config and save the file, so the config reloads.
  3. Reload the edit view (with more than one request in flight around the reload, e.g. the page plus a form-state server function, or two tabs open).
  4. The new field is sometimes missing from the form, and stays missing on further reloads until the dev server is restarted. The server log may show Cannot use 'in' operator to search for 'hidden' in undefined.

The timing depends on which request reaches the cache first after the reload, so it does not happen on every edit; it is more frequent on larger configs where a render takes longer.

Unit-level reproduction (fails on main):

const previous = getSchemaMap({ collectionSlug: 'pages', config: configA, i18n })
const next = getSchemaMap({ collectionSlug: 'pages', config: configB, i18n }) // configB adds a field
expect(next.has('pages.summary')).toBe(true) // fails: returns the map built from configA

Which area(s) are affected?

area: ui

Environment Info

Payload: 4.x (main)
Next.js: 16 (next dev)
Node.js: 24
OS: Linux / macOS

Development mode only (config reload / HMR). Production builds load the config once, so the caches never see a second config.

Activity

  1. added
    area: ui
    on Oct 28, 2026
  2. added
    area: ui
    and removed
    area: ui
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions