A `ui:field` naming a field that re-enters `SchemaField` recurses until the heap runs out

Author: heath-freenomeCreated Sep 29, 2026Updated Sep 30, 2026
Labelsbug

Prerequisites

  • I have searched the existing issues
  • I understand that providing a SSCCE example is tremendously useful to the maintainers
  • I have read the documentation

What theme are you using?

core

Version

7.x (v7 branch, measured at 0f167b7ab with the fix-5333 work on top)

Current Behavior

A ui:field naming a field that renders SchemaField again is handed back the same uiSchema, so it re-enters itself and each pass renders another one. The form takes the tab down:

typescript
const schema: RJSFSchema = { type: 'object', properties: { val: { type: 'string' } } };
render(<Form schema={schema} uiSchema={{ val: { 'ui:field': 'SchemaField' } }} validator={validator} />, node);
// FATAL ERROR: Ineffective mark-compacts near heap limit — JavaScript heap out of memory

CoreUiOptionsChecks.ts:162-171 puts both 'SchemaField' and 'FallbackField' in the typed ui:field union, so the types offer the two names that do this. A custom wrapper field that renders registry.fields.SchemaField with its own props was reported to hit the same loop; I have not reproduced that variant myself.

One instance is fixed, the class is not

#5362 fixes the FallbackField instance, because that field builds the uiSchemas for its two children and can shadow field on both of them. SchemaField hands the caller's uiSchema to the field a ui:field names, so nothing shadows it there.

The same PR also leaves a gap in the fix it does make. MultiSchemaField passes the main uiSchema — and with it the shadow — down to an option only when there is no uiSchema.anyOf/oneOf array (selectOptionUiSchema()). So with a global entry naming the fallback field, whether an option renders a second type selector depends on an unrelated part of the uiSchema:

typescript
uiSchema: { 'ui:globalOptions': { field: 'FallbackField' }, val: { anyOf: [{}, {}] } }
// 3 type selectors; drop the per-option array and there are 2

It is bounded rather than infinite, but it is inconsistent.

Expected Behavior

A ui:field naming a field that routes back into SchemaField should be honored once — the field renders — and then not re-applied to what that field renders.

Shadowing field once in SchemaField, on the uiSchema handed to a named field that re-enters SchemaField, would cover every spelling (ui:field, ui:options.field, ui:globalOptions.field) and both fields, and would reach option subschemas as well since each option's own SchemaField would apply the same rule.

Two things for whoever takes it:

  1. getDisplayLabel() reads ui:field. getDisplayLabel.ts:61-63 sets displayLabel to false whenever ui:field is present, so shadowing it for arbitrary custom fields would change their labels. The guard has to apply only to a field that routes back into SchemaField, not to custom fields generally.
  2. A field that builds a fresh uiSchema still needs its own shadow. FallbackField's type selector is one: its uiSchema is constructed rather than inherited, so a global entry reaches it however the parent's uiSchema was treated.

Steps To Reproduce

The snippet above, with no interaction. For the option-array inconsistency, render the second snippet's uiSchema against { type: 'object', properties: { val: { type: ['string', 'number'], anyOf: [{ minLength: 2 }, { maximum: 5 }] } } } with useFallbackUiForUnsupportedType, and count [id$="___internal_type_selector"] with and without the val: { anyOf: [{}, {}] } entry.

Anything else?

Raised in review of #5362. That PR fixes the FallbackField instance because it was newly reachable there — the configuration used to crash earlier for a different reason — and deliberately leaves the general case here: a correct fix turns on the getDisplayLabel() question above, which is a decision about custom fields rather than about the fallback UI.

  • OS: macOS 15 (Darwin 25.6.0)
  • Node: 24
  • npm: pnpm 12

Source: rjsf-team/react-jsonschema-form