Repository navigation
fix: $config() synthesized getType() recurses infinitely when inherited as own static (#8867 follow-up) - #8869
Merged
Conversation
…d as own static (#8867 follow-up)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
marked this pull request as ready for review
July 21, 2026 12:46
potatowagon
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7 and
zurfyx
as code owners
July 21, 2026 12:46
etrepum
approved these changes
Jul 21, 2026
Merged
11 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem this solves
After #8867, registering or resolving the type of a
$config({extends})node subclass can infinite-loop and crash withRangeError: Maximum call stack size exceeded— but only under compiled class output (Babel/transpiled bundles, e.g. Meta'swww). Any editor that registers such a node (a hashtag node, a code-highlight node, a customTextNode/ElementNodesubclass configured via$config({extends})) fails to initialize.Concrete breakage (real consumers)
In Meta's
www, nodes likeHashtagNodeandCodeHighlightNodeare defined as$config({extends: TextNode})subclasses. When the Lexical bundle containing #8867 was synced in, 7 previously-green test suites started failing — 118 tests — every one blowing the stack ingetType():Root cause
#8867 fixed a real bug — a subclass inheriting a superclass's synthesized
getType()and registering under the wrong type (collision). Its guard defers to the base for a foreignthis:But
getStaticNodeConfigderives a node's type by callingklass.getType():Native ES classes don't inherit statics as own properties — but compiled class output copies the superclass's synthesized closure down onto the subclass as an own static (its captured
synthesizedForKlassstill points at the superclass). That closes the loop:Because it only manifests under transpilation, Lexical's own (untranspiled) unit tests — including #8867's collision tests — never caught it.
The fix
Brand the synthesized closure with an internal symbol, and never call a synthesized
getType()to derive the type ingetStaticNodeConfig— derive it from the$configrecord instead. A genuine user-definedstatic getType()is still called exactly as before.This breaks the cycle while fully preserving #8867's collision fix.
Test plan
LexicalNode.test.tsthat reconstructs the compiled shape (a synthesized closure installed as an own static on a subclass whose identity differs from the closure'ssynthesizedForKlass). It throwsRangeError: Maximum call stack size exceededonmainand passes with this fix.tsc -p ./tsconfig.json --noEmit— clean.vitest --project unitLexicalNode.test— 100/100 pass (including fix: $config() synthesized getType() inherited by subclasses causes node-type collision (#8640) #8867's existing collision tests).Lexical.dev.jswith this change in Meta'swwwand re-running the 7 previously-failing suites takes them from 118 failed / 30 passed to 148 passed / 148 total.References
$config()portgetType()collision fix (this recursion is a follow-up to it)Scope
getType()recursion only. Touches the$config()synthesis runtime (LexicalUtils.ts) — disjoint from the separateimportJSONnullable BC regression, which is fixed in #8868.