Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Add a log when react-dom is running on RSC instead of SSR #27561

Closed
wants to merge 7 commits into from

Conversation

arjunsohal12
Copy link

Addresses issue #27478, providing a better error message when react-dom is running on RSC instead of SSR by checking when ReactCurrentCache is undefined and throwing a more descriptive error.

Code changes:

  if (enableCache) {
    if (ReactCurrentCache === undefined) {
        throw new Error(
            'The "react" package in this environment is not configured correctly. The "react-server" condition must be enabled in any environment that runs React Server Components.',
        );
    }
    prevCacheDispatcher = ReactCurrentCache.current;
    ReactCurrentCache.current = DefaultCacheDispatcher;
};

What did you do to test it:

Reproduced the issue, checked if the correct error message was shown.

@facebook-github-bot
Copy link

Hi @arjunsohal12!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@react-sizebot
Copy link

react-sizebot commented Oct 21, 2023

Comparing: 8c85b02...45aa5c0

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 174.94 kB 174.94 kB = 54.44 kB 54.44 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 177.06 kB 177.06 kB = 55.12 kB 55.12 kB
facebook-www/ReactDOM-prod.classic.js = 567.28 kB 567.28 kB = 99.85 kB 99.85 kB
facebook-www/ReactDOM-prod.modern.js = 551.14 kB 551.14 kB = 96.94 kB 96.94 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/react-server/cjs/react-server.production.min.js +0.57% 34.67 kB 34.87 kB +0.83% 10.98 kB 11.08 kB
oss-stable/react-server/cjs/react-server.production.min.js +0.57% 34.67 kB 34.87 kB +0.83% 10.98 kB 11.08 kB
oss-experimental/react-server/cjs/react-server.production.min.js +0.53% 37.42 kB 37.62 kB +0.75% 11.69 kB 11.78 kB
oss-stable-semver/react-dom/cjs/react-dom-server.bun.production.min.js +0.26% 75.60 kB 75.80 kB +0.39% 23.00 kB 23.09 kB
oss-stable/react-dom/cjs/react-dom-server.bun.production.min.js +0.26% 75.63 kB 75.83 kB +0.38% 23.02 kB 23.11 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.min.js +0.26% 77.04 kB 77.24 kB +0.44% 23.85 kB 23.95 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.min.js +0.26% 77.06 kB 77.26 kB +0.44% 23.87 kB 23.98 kB
oss-stable-semver/react-dom/cjs/react-dom-server-legacy.node.production.min.js +0.26% 77.48 kB 77.68 kB +0.38% 23.76 kB 23.85 kB
oss-stable/react-dom/cjs/react-dom-server-legacy.node.production.min.js +0.26% 77.51 kB 77.71 kB +0.37% 23.78 kB 23.87 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.min.js +0.25% 78.50 kB 78.70 kB +0.39% 23.78 kB 23.88 kB
oss-stable-semver/react-dom/cjs/react-dom-server.edge.production.min.js +0.25% 78.96 kB 79.15 kB +0.46% 24.72 kB 24.84 kB
oss-stable/react-dom/cjs/react-dom-server.edge.production.min.js +0.25% 78.98 kB 79.18 kB +0.46% 24.75 kB 24.86 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.min.js +0.25% 80.34 kB 80.54 kB +0.40% 24.54 kB 24.63 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.min.js +0.24% 82.75 kB 82.95 kB +0.40% 25.22 kB 25.32 kB
oss-experimental/react-dom/cjs/react-dom-server.edge.production.min.js +0.23% 84.52 kB 84.72 kB +0.34% 25.99 kB 26.08 kB

Generated by 🚫 dangerJS against 45aa5c0

@gaearon
Copy link
Collaborator

gaearon commented Nov 14, 2023

It would be nice to have a better error, but this specific place seems too specific and mostly accidental. It might crash somewhere else later. Maybe react-dom could just have a react-server conditions entry point that logs a good message? Not sure if it's meant to be unsupported completely or just warn.

Copy link

github-actions bot commented Apr 5, 2024

This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.

@github-actions github-actions bot added the Resolution: Stale Automatically closed due to inactivity label Apr 5, 2024
Copy link

Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

@github-actions github-actions bot closed this Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants