Repository navigation
[lexical-website] Bug Fix: Fix crash on /docs/error page from undefined process - #8557
Merged
Merged
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
marked this pull request as ready for review
May 25, 2026 05:17
etrepum
requested review from
acywatson,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
May 25, 2026 05:17
zurfyx
approved these changes
May 27, 2026
Merged
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.
Description
The minified production build of Lexical points users to
https://lexical.dev/docs/error?code=Nfor the full error text, but thatpage crashes on load.
ErrorCodePagereadsprocess.env.FB_INTERNALin browser code to decidewhether to load
scripts/error-codes/codes.json. The OSS Docusaurus buildnever defines
processfor the client bundle (onlyBufferis polyfilled,and
customFieldsdoesn't expose it), so the access throwsReferenceError: process is not definedand the page never renders.This PR defines the token at build time via the bundler's
DefinePluginindocusaurus.config.ts, soprocess.env.FB_INTERNALis statically replacedin the browser bundle (
""in OSS, honoring the env var if it is set). TheErrorCodePagesource is left unchanged, matching what Meta's internalbundler already expects.
Closes #8556
Test plan
Before
Visiting
/docs/error?code=94crashes withUncaught ReferenceError: process is not defined. Workaround is runningprocess = {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 buildsucceeds, and the compilederror-page chunk contains no
processreference and noFB_INTERNALstring. The
useEffectcompiles to an unconditional dynamic import of thecodes chunk:
The codes chunk builds and includes code
94, so visiting/docs/error?code=94now renders the full error message instead ofcrashing.