Skip to content

[lexical][lexical-website] Bug Fix: Homepage crash from optimized dev build - #8861

Merged
etrepum merged 5 commits into
meta:mainfrom
etrepum:claude/homepage-crash-embedded-2bxeua
Jul 21, 2026
Merged

etrepum merged 5 commits into
meta:mainfrom
etrepum:claude/homepage-crash-embedded-2bxeua

Conversation

@etrepum

@etrepum etrepum commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Description

The website homepage crashed entirely with
nV (type tab) must implement a static clone method since its constructor has 1 required arguments (expecting 0), taking down every embedded example.

Root cause: the website bundles the dev build of lexical (so the node registration invariants are live) but minifies it for production. The minifier strips arg = undefined default-parameter assignments, which inflates Function.length for node constructors. The existing TextNode.length === 0 guard detects non-ES6 compiler output but not a minified build — TextNode's own text = '' default survives minification ('' is not undefined) — so the clone/importJSON klass.length === 0 invariants false-fired at runtime and crashed the first example to mount.

This PR:

  • lexical: only run the clone/importJSON length invariants when the build is unoptimized, detected via TextNode.name === 'TextNode' (class names are mangled once the output is minified).
  • lexical-website: wrap each embedded homepage example in its own error boundary (built on @lexical/react's LexicalErrorBoundary) so a single failing example no longer takes down the whole page. The fallback renders a data-example-error marker.
  • lexical-website: add a homepage smoke test that loads the built site in a browser and fails if an embedded example throws at runtime, wired into the core CI job. A green build alone does not catch this class of failure.

Closes #8860

Test plan

Before

  • Built the website (pnpm --filter @lexical/website build) and loaded the homepage in Chromium: the first example threw the clone invariant and the page failed to render.
  • Injected a client-only render crash into one example and ran the new test-examples check without the error boundary: the entire homepage went down.

After

  • pnpm --filter @lexical/website build succeeds and the new pnpm --filter @lexical/website test-examples smoke check passes (7 editors mounted, no runtime errors, no broken examples).
  • Negative test: injected a client-only crash into one example — the build still succeeded, the error boundary isolated the failure (the other examples kept working), and test-examples failed with exit 1 naming the broken example. Reverted after verifying.
  • Unit tests pass for LexicalUtils, LexicalNode, LexicalNodeState, and DecoratorTextExtension (263 tests); eslint and prettier are clean.

… build

## Description

The website homepage crashed entirely with
`nV (type tab) must implement a static clone method since its constructor has
1 required arguments (expecting 0)`, taking down every embedded example.

Root cause: the website bundles the dev build of `lexical` (so the node
registration invariants are live) but minifies it for production. The
minifier strips `arg = undefined` default-parameter assignments, which
inflates `Function.length` for node constructors. The existing
`TextNode.length === 0` guard detects non-ES6 compiler output but not a
minified build — `TextNode`'s own `text = ''` default survives minification
(`''` is not `undefined`) — so the clone/`importJSON` `klass.length === 0`
invariants false-fired at runtime and crashed the first example to mount.

This PR:

- **lexical**: only run the clone/`importJSON` length invariants when the
  build is unoptimized, detected via `TextNode.name === 'TextNode'` (class
  names are mangled once the output is minified).
- **lexical-website**: wrap each embedded homepage example in its own error
  boundary (built on `@lexical/react`'s `LexicalErrorBoundary`) so a single
  failing example no longer takes down the whole page. The fallback renders a
  `data-example-error` marker.
- **lexical-website**: add a homepage smoke test that loads the built site in
  a browser and fails if an embedded example throws at runtime, wired into the
  core CI job. A green `build` alone does not catch this class of failure.

Closes meta#8860

## Test plan

### Before

- Built the website (`pnpm --filter @lexical/website build`) and loaded the
  homepage in Chromium: the first example threw the clone invariant and the
  page failed to render.
- Injected a client-only render crash into one example and ran the new
  `test-examples` check *without* the error boundary: the entire homepage went
  down.

### After

- `pnpm --filter @lexical/website build` succeeds and the new
  `pnpm --filter @lexical/website test-examples` smoke check passes
  (7 editors mounted, no runtime errors, no broken examples).
- Negative test: injected a client-only crash into one example — the build
  still succeeded, the error boundary isolated the failure (the other examples
  kept working), and `test-examples` failed with exit 1 naming the broken
  example. Reverted after verifying.
- Unit tests pass for `LexicalUtils`, `LexicalNode`, `LexicalNodeState`, and
  `DecoratorTextExtension` (263 tests); eslint and prettier are clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Jul 19, 2026 3:19pm
lexical-playground Ready Ready Preview Jul 19, 2026 3:19pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 19, 2026
… WebKit

The `History` and `meta#1055 fast-typing-undo` specs flaked on the
mac-plain/webkit suite: after an undo the assertion for an empty paragraph
saw text that grew across retries (`h` → `he` → `hell`). On WebKit the input
events dispatched by `keyboard.type()` can be applied after the call
resolves, so the undo raced ahead of the typing and the still-queued input
re-applied the text.

The suite relies on `await assertHTML(...)` (which polls via `toPass`) as an
implicit synchronization barrier that lets the editor settle between actions.
Two gaps removed those barriers:

- History.spec.mjs had five `assertHTML(...)` calls that were never awaited
  (floating promises), so the following undo/redo/type ran before the editor
  reached the asserted state.
- The meta#1055 test typed `hello` and undid immediately with no assertion in
  between, so the undo could fire before the typing settled.

Await the five assertions and add an intermediate assertion of the typed
state before the first undo in meta#1055. No production code changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@etrepum
etrepum added this pull request to the merge queue Jul 21, 2026
Merged via the queue into meta:main with commit 3429b57 Jul 21, 2026
44 checks passed
@etrepum etrepum mentioned this pull request Jul 29, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 18f1ab00 Deployed Jul 19, 2026 by vercel[bot]
Preview – lexical-playground — 18f1ab00 Deployed Jul 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Website crashes with 'clone method... expecting 0' error"

3 participants