Skip to content

Feature Request: Need ability to debug checksum mismatch in production environment #10016

@lingyan

Description

@lingyan

Do you want to request a feature or report a bug?

Feature

What is the current behavior?

Currently, if checksum mismatch happens when mounting React tree on server rendered markup, we can only get markup difference in dev environment. Reality is, mismatches happen more in production env, where there are much bigger variety of user contexts that can trigger the mismatch. It is very hard to reproduce the mismatch scenarios in dev environment, without knowing where the markup difference is.

What is the expected behavior?

What I'm proposing is to provide apps a way to obtain the markup difference even in production environment, so that the diffs can be reported back to developers for debugging mismatch root cause.

Fiber would probably change how checksum works. But before it is ready, we still need ability to debug this issue in production env.

I was trying something like this: lingyan/react@master...reportMarkupDiff It works but probably is not the best approach. The idea is simple though:

  • provide a way for application to control which react tree to report markup diff upon checksum mismatch, as application might only care about mismatch in a subset of the React trees mounted and there would be concerns with markup normalization cost:
    • I am using a data attribute on container node, but it is not the best approach, since container can also be document node.
    • I thought about two alternative ways but neither of them is perfect:
      • add reportMarkupDiff option to ReactDom.render() signature
      • add a prop like reportMarkupDiff to the element being rendered
  • allow application to collect the markup diff even in production environment:
    • I'm setting the markup difference as the value of the same data attribute on the container node

Please share your thoughts and ideas. I am up for raising a PR to implement the most ideal approach. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions