Skip to content

Include editor namespace in infinite-update-loop detector error#8612

Merged
potatowagon merged 1 commit into
mainfrom
lexi/cascade-error-namespace
Jun 2, 2026
Merged

Include editor namespace in infinite-update-loop detector error#8612
potatowagon merged 1 commit into
mainfrom
lexi/cascade-error-namespace

Conversation

@potatowagon

@potatowagon potatowagon commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

The infinite-update-loop circuit-breaker added in #8542 fires when update listeners endlessly re-enqueue updates (editor._cascadeCount > 99). It is working as intended, but its output is currently hard to act on.

When the loop fires, the thrown error is surfaced via editor._onError at the core boundary, so the aggregated stack is entirely minified core frames with an empty deferred stack. There is no way to attribute the loop to a specific editor instance or plugin without a dev repro — and the loop often only reproduces under specific product conditions.

This appends the editor's namespace to the thrown error message using the existing invariant(%s) parameterization:

invariant(
  false,
  'One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: %s',
  editor._config.namespace,
);

editor._config.namespace is set distinctly per product/editor, so this immediately partitions the aggregated error by editor in error reporting — with zero new logging surface.

Why this shape

  • No behavior change — same circuit-breaker, same drop-queue, same _onError path. Only the message string gains a %s arg.
  • Uses the existing invariant(%s) pattern, so it slots into the error-code / codes.json minification cleanly.
  • Kept minimal (namespace only). A follow-up could add the first non-core stack frame if attribution is still ambiguous.

Test plan

Extended the existing Detects infinite recursivity on update listeners test in packages/lexical/src/__tests__/unit/LexicalEditor.test.tsx to assert the thrown error message contains the editor's namespace, in addition to the existing /endlessly enqueueing/ assertion.


This PR was raised by Navi on behalf of Sherry Wong, at the request of the Lexical sync oncall.

The circuit-breaker added in #8542 fires when update listeners endlessly
re-enqueue updates (cascade count > 99). In production the resulting error is
logged via editor._onError at the core boundary, so the stack is fully
minified core frames -- there is no way to attribute the loop to a specific
editor instance or plugin without a dev repro.

Append the editor's namespace to the thrown error message via the existing
invariant %s parameterization. editor._config.namespace is set distinctly per
product/editor, so this partitions the aggregated error by tool with zero new
logging surface and no behavior change.

Extends the existing infinite-recursion test to assert the namespace appears
in the error message.
@vercel

vercel Bot commented Jun 2, 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 Jun 2, 2026 4:54am
lexical-playground Building Building Preview Jun 2, 2026 4:54am

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 Jun 2, 2026
@potatowagon potatowagon added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit 299fd37 Jun 2, 2026
38 checks passed
@etrepum etrepum mentioned this pull request Jun 25, 2026
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.

2 participants