Skip to content

Conversation

@sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented Jun 29, 2025

Stacked on #33666.

If we ever get a future reference to a cycle and that reference gets eagerly parsed before the target has loaded then we can end up with a cycle that never gets resolved. That's because our cycle resolution only works if the cyclic future reference is created synchronously within the parsing path of the child.

I haven't been able to construct a normal scenario where this would break. So this doesn't fail any tests. However, I can construct it with debug info since those are eagerly evaluated. It's also a prerequisite if the debug data can come out of order, like if it's on a different stream.

The fix here is to make all the internal dependencies in the "listener" list into introspectable objects instead of closures. That way we can traverse the list of dependencies of a blocked reference to see if it ends up in a cycle and therefore skip the reference.

It would be nice to address this once and for all to be more resilient to server changes, but I'm not sure if it's worth this complexity and the extra CPU cost of tracing the dependencies. Especially if it's just for debug data.

closes #32316
fixes vercel/next.js#72104

@react-sizebot
Copy link

react-sizebot commented Jun 29, 2025

The size diff is too large to display in a single comment. The GitHub action for this pull request contains an artifact called 'sizebot-message.md' with the full message.

Generated by 🚫 dangerJS against 7b52178

Copy link
Collaborator

@unstubbable unstubbable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it!

I haven't been able to construct a normal scenario where this would break. So this doesn't fail any tests.

This actually fixes vercel/next.js#72104, and we can close #32316 (an inferior solution). I've added the test from that PR to this one.

@sebmarkbage
Copy link
Collaborator Author

Oh weird. I actually originally had that test in this branch but I didn't think it would fix it. I guess I did something along the way that did fix it.

@sebmarkbage sebmarkbage merged commit 3cfcdfb into facebook:main Jun 29, 2025
241 checks passed
sebmarkbage added a commit to sebmarkbage/react that referenced this pull request Dec 3, 2025
FlightReplyServer are for client->server and ReactFlightClient is for server->client. They're not 100% symmetrical.

We did a number of refactors to ReactFlightClient in PRs like facebook#29823 and facebook#33664 to change the structure of the resolution.
This PR brings those changes to synchronize the two approaches. Which addresses
deep resolution of cycles and deferred error handling.

This also fixes a critical security vulnerability.
eps1lon pushed a commit that referenced this pull request Dec 3, 2025
We did a bunch of refactors to ReactFlightClient in PRs like #29823 and #33664.

This brings a bunch of those related refactors to the equivalent FlightReplyServer. Such as deep resolution of cycles and deferred error handling.
sebmarkbage added a commit that referenced this pull request Dec 3, 2025
FlightReplyServer are for client->server and ReactFlightClient is for
server->client. They're not 100% symmetrical.

We did a number of refactors to ReactFlightClient in PRs like #29823 and
#33664 to change the structure of the resolution. This PR brings those
changes to synchronize the two approaches. Which addresses deep
resolution of cycles and deferred error handling.

This also fixes a critical security vulnerability.
eps1lon pushed a commit that referenced this pull request Dec 3, 2025
We did a bunch of refactors to ReactFlightClient in PRs like #29823 and #33664.

This brings a bunch of those related refactors to the equivalent FlightReplyServer. Such as deep resolution of cycles and deferred error handling.
eps1lon pushed a commit that referenced this pull request Dec 3, 2025
We did a bunch of refactors to ReactFlightClient in PRs like #29823 and #33664.

This brings a bunch of those related refactors to the equivalent FlightReplyServer. Such as deep resolution of cycles and deferred error handling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specific data/props case causes infinite loading

5 participants