Skip to content

[lexical-website] Bug Fix: Fix crash on /docs/error page from undefined process - #8557

Merged
etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/lexical-website-bug-Ze4RC
May 27, 2026
Merged

etrepum merged 2 commits into
meta:mainfrom
etrepum:claude/lexical-website-bug-Ze4RC

Conversation

@etrepum

@etrepum etrepum commented May 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The minified production build of Lexical points users to
https://lexical.dev/docs/error?code=N for the full error text, but that
page crashes on load.

ErrorCodePage reads process.env.FB_INTERNAL in browser code to decide
whether to load scripts/error-codes/codes.json. The OSS Docusaurus build
never defines process for the client bundle (only Buffer is polyfilled,
and customFields doesn't expose it), so the access throws
ReferenceError: process is not defined and the page never renders.

This PR defines the token at build time via the bundler's DefinePlugin in
docusaurus.config.ts, so process.env.FB_INTERNAL is statically replaced
in the browser bundle ("" in OSS, honoring the env var if it is set). The
ErrorCodePage source is left unchanged, matching what Meta's internal
bundler already expects.

Closes #8556

Test plan

Before

Visiting /docs/error?code=94 crashes with
Uncaught ReferenceError: process is not defined. Workaround is running
process = {env:{}} in the console and clicking "try again".

After

https://lexical-git-fork-etrepum-claude-lexical-web-fbcf0a-fbopensource.vercel.app/docs/error?code=94 does not crash

pnpm -C packages/lexical-website run build succeeds, and the compiled
error-page chunk contains no process reference and no FB_INTERNAL
string. The useEffect compiles to an unconditional dynamic import of the
codes chunk:

useEffect(() => { t.e("3595").then(t.t.bind(t, 45078, 19)).then(e => r(e)) }, [])

The codes chunk builds and includes code 94, so visiting
/docs/error?code=94 now renders the full error message instead of
crashing.

claude added 2 commits May 25, 2026 04:19
The error documentation page accessed process.env.FB_INTERNAL directly
in browser code, throwing a ReferenceError since `process` is undefined
in the browser. Guard the access so the page loads correctly.

https://claude.ai/code/session_01L7XcgcqHmfTH3qeey3Uzdi
The error code docs page read process.env.FB_INTERNAL in client code,
but `process` is undefined in the browser, throwing a ReferenceError and
crashing the page. Define the token via the bundler's DefinePlugin so the
reference is statically replaced at build time, and revert the runtime
guard in ErrorCodePage.

https://claude.ai/code/session_01L7XcgcqHmfTH3qeey3Uzdi
@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 May 25, 2026
@vercel

vercel Bot commented May 25, 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, Comment May 25, 2026 5:06am
lexical-playground Ready Ready Preview, Comment May 25, 2026 5:06am

Request Review

@etrepum
etrepum added this pull request to the merge queue May 27, 2026
Merged via the queue into meta:main with commit 1696c6b May 27, 2026
37 checks passed
@etrepum
etrepum deleted the claude/lexical-website-bug-Ze4RC branch May 27, 2026 14:14
@etrepum etrepum mentioned this pull request May 28, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 3e3047bd Deployed May 25, 2026 by vercel[bot]
Preview – lexical-playground — 3e3047bd Deployed May 25, 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: Minified error messages point to a page that crashes

3 participants