refactor: force infinite render loop detection to throw instead of wa…#36531
refactor: force infinite render loop detection to throw instead of wa…#36531dev-himanshu-x wants to merge 1 commit into
Conversation
…rning and remove related feature flags
|
Hi @dev-himanshu-x! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
…rning and remove related feature flags
Summary
This PR addresses the asymmetric behavior between synchronous and passive infinite render loop detection (originally raised in #36423). Currently, the
NESTED_PASSIVE_UPDATE_LIMITguard foruseEffectloops is completely wrapped insideif (__DEV__), causing infinite render loops to fail silently and freeze browser tabs in production environments.This change:
NESTED_PASSIVE_UPDATE_LIMITcheck out of the__DEV__guard block so it is included in production builds.console.errorto an explicitthrow new Error(...)across both development and production. This ensures thatuseEffectinfinite loops correctly trigger Error Boundaries, root uncaught error options, and telemetry monitoring tools (such as Sentry or Datadog).enableInfiniteRenderLoopDetectionfeature flags and instrumentations that were falling back to casual console warnings, reducing dead code pathways inReactFiberWorkLoop.js.Fixes #36423
How did you test this change?
yarn testto verify that no core reconciler behaviors were broken.yarn test --prodand built the standalone production bundles viayarn build react/index,react-dom/index --type=NODEto guarantee the check compiles successfully without__DEV__.useEffectsetting state. The production build now safely crashes the breaking tree and surfaces a catchable error stack trace immediately instead of freezing the single thread.