Skip to content

Fix/unhandled promise rejection stylesheet loading#35415

Closed
Lihexs wants to merge 3 commits intofacebook:mainfrom
Lihexs:fix/unhandled-promise-rejection-stylesheet-loading
Closed

Fix/unhandled promise rejection stylesheet loading#35415
Lihexs wants to merge 3 commits intofacebook:mainfrom
Lihexs:fix/unhandled-promise-rejection-stylesheet-loading

Conversation

@Lihexs
Copy link
Copy Markdown

@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
@github-actions
Copy link
Copy Markdown

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 Mar 26, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

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 2, 2026
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.

1 participant