Skip to content

Conversation

@Lihexs
Copy link

@Lihexs Lihexs commented Dec 26, 2025

Summary

Fix UnhandledPromiseRejection crash in Jest when CSS stylesheet resources fail to load.

When a stylesheet fails to load, the Promise created with link.onerror = reject
was not being caught, causing Node.js/Jest to crash with UnhandledPromiseRejection.

Changes:

  1. Added .catch(() => {}) to stylesheet loading Promises in ReactFiberConfigDOM.js (3 locations)
  2. Fixed test assertion order in ReactDOMFloat-test.js to match actual event dispatch order
  3. Unskipped the "can delay commit until css resources error" test

Note: The empty .catch() handler is intentional - React already tracks the error state via state.loading |= Errored, so the catch is only needed to prevent Node.js from crashing on unhandled rejection.

How did you test this change?

Unskipped and ran the previously failing test:

yarn test packages/react-dom/src/__tests__/ReactDOMFloat-test.js -t "can delay commit until css resources error"

Before fix: Jest crashes with UnhandledPromiseRejection

After fix: Test passes successfully

@meta-cla
Copy link

meta-cla bot commented Dec 26, 2025

Hi @Lihexs!

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 [email protected]. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Dec 26, 2025
@Lihexs Lihexs closed this Dec 26, 2025
@Lihexs Lihexs deleted the fix-stylesheet-promise-rejection branch December 26, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant