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 meta-cla bot added the CLA Signed label Dec 26, 2025
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