Commit Graph
16302 Commits
Author SHA1 Message Date
rickhanlonii 1b27d1e4ad Remove enableComponentStackLocations (#31764)
This has landed everywhere

DiffTrain build for [3ad17ecd31](https://github.com/facebook/react/commit/3ad17ecd313a8e53b339adf8052e35b3d73f8c62)
2024-12-13 13:00:30 -08:00
rickhanlonii aa9b74aa4f Remove enableAsyncActions (#31757)
Based on https://github.com/facebook/react/pull/31756

This is landed everywhere

DiffTrain build for [ef63718a27](https://github.com/facebook/react/commit/ef63718a27407b6d6b262d6be92e6bf0a87ff1a3)
2024-12-13 11:05:30 -08:00
rickhanlonii 9f5fb91030 Remove disableIEWorkarounds (#31756)
Based off https://github.com/facebook/react/pull/31755

This is landed everywhere.

DiffTrain build for [fb12845d77](https://github.com/facebook/react/commit/fb12845d779667b35cc7f44eee6bea47f4db72ba)
2024-12-13 09:33:56 -08:00
jackpope 5b45911189 Fix useResourceEffect in Fizz (#31758)
We're seeing errors when testing useResourceEffect in SSR and it turns
out we're missing the noop dispatcher function on Fizz.

I tested a local build with this change and it resolved the late
mutation errors in the e2e tests.

DiffTrain build for [17ca4b157f](https://github.com/facebook/react/commit/17ca4b157fcba6c734583513353ba72376a7ba2d)
2024-12-13 08:33:45 -08:00
rickhanlonii f0381ca1dc Remove consoleManagedByDevToolsDuringStrictMode (#31755)
This is enabled everywhere except the test renderers, which don't use
it.

DiffTrain build for [4dff0e62b2](https://github.com/facebook/react/commit/4dff0e62b2320d8c97746a16c95efd9c9ad0bc07)
2024-12-13 08:13:39 -08:00
sebmarkbage 2a2d2f8273 [Fiber] Use hydration lanes when scheduling hydration work (#31751)
When scheduling the initial root and when using
`unstable_scheduleHydration` we should use the Hydration Lanes rather
than the raw update lane. This ensures that we're always hydrating using
a Hydration Lane or the Offscreen Lane rather than other lanes getting
some random hydration in it.

This fixes an issue where updating a root while it is still hydrating
causes it to trigger client rendering when it could just hydrate and
then apply the update on top of that.

It also fixes a potential performance issue where
`unstable_scheduleHydration` gets batched with an update that then ends
up forcing an update of a boundary that requires it to rewind to do the
hydration lane anyway. Might as well just start with the hydration
without the update applied first.

I added a kill switch (`enableHydrationLaneScheduling`) just in case but
seems very safe given that using `unstable_scheduleHydration` at all is
very rare and updating the root before the shell hydrates is extremely
rare (and used to trigger a recoverable error).

DiffTrain build for [d5e8f79cf4](https://github.com/facebook/react/commit/d5e8f79cf4d11fa7eee263b3f937deecbe65ffd7)
2024-12-12 20:13:02 -08:00
noahlemen 0bcbbf0082 Make enableOwnerStacks dynamic (#31661)
following up on https://github.com/facebook/react/pull/31287, fixing
tests

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [a4964987dc](https://github.com/facebook/react/commit/a4964987dc140526702e996223fe7ee293def8ac)
2024-12-11 09:07:47 -08:00
eps1lon 4e4144e71c react-hooks/rules-of-hooks: Improve support for do/while loops (#31720)
DiffTrain build for [7c4a7c9ddf](https://github.com/facebook/react/commit/7c4a7c9ddf2f1c8e223565af1256ea201ec0f303)
2024-12-10 13:53:31 -08:00
sebmarkbage 0558177043 Clean up findFiberByHostInstance from DevTools Hook (#31711)
The need for this was removed in
https://github.com/facebook/react/pull/30831

Since the new DevTools version has been released for a while and we
expect people to more or less auto-update. Future versions of React
don't need this.

Once we remove the remaining uses of `getInstanceFromNode` e.g. in the
deprecated internal `findDOMNode`/`findNodeHandle` and the event system,
we can completely remove the tagging of DOM nodes.

DiffTrain build for [3b597c0576](https://github.com/facebook/react/commit/3b597c0576977773910c77e075cc6d6308decb04)
2024-12-10 08:41:30 -08:00
gnoff e3aab58ef9 Register Suspense retry handlers in commit phase (#31667)
To avoid GC pressure and accidentally hanging onto old trees Suspense
boundary retries are now implemented in the commit phase. I used the
Callback flag which was previously only used to schedule callbacks for
Class components. This isn't quite semantically equivalent but it's
unused and seemingly compatible.

DiffTrain build for [de68d2f4a2](https://github.com/facebook/react/commit/de68d2f4a2403ad1ef46a3036ddc1f9080640588)
2024-12-04 08:09:37 -08:00
gnoff 8834a5b4ae Client render dehydrated Suspense boundaries on document load (#31620)
When streaming SSR while hydrating React will wait for Suspense
boundaries to be revealed by the SSR stream before attempting to hydrate
them. The rationale here is that the Server render is likely further
ahead of whatever the client would produce so waiting to let the server
stream in the UI is preferable to retrying on the client and possibly
delaying how quickly the primary content becomes available. However If
the connection closes early (user hits stop for instance) or there is a
server error which prevents additional HTML from being delivered to the
client this can put React into a broken state where the boundary never
resolves nor errors and the hydration never retries that boundary
freezing it in it's fallback state.

Once the document has fully loaded we know there is not way any
additional Suspense boundaries can arrive. This update changes react-dom
on the client to schedule client renders for any unfinished Suspense
boundaries upon document loading.

The technique for client rendering a fallback is pretty straight
forward. When hydrating a Suspense boundary if the Document is in
'complete' readyState we interpret pending boundaries as fallback
boundaries. If the readyState is not 'complete' we register an event to
retry the boundary when the DOMContentLoaded event fires.

To test this I needed JSDOM to model readyState. We previously had a
temporary implementation of readyState for SSR streaming but I ended up
implementing this as a mock of JSDOM that implements a fake readyState
that is mutable. It starts off in 'loading' readyState and you can
advance it by mutating document.readyState. You can also reset it to
'loading'. It fires events when changing states.

This seems like the least invasive way to get closer-to-real-browser
behavior in a way that won't require remembering this subtle detail
every time you create a test that asserts Suspense resolution order.

DiffTrain build for [16d2bbbd1f](https://github.com/facebook/react/commit/16d2bbbd1f1617d636ea0fd271b902a12a763c27)
2024-12-03 13:20:46 -08:00
poteto 61d48e4526 [crud] Only export uRC when flag is enabled (#31617)
It's tricky to do feature detection of uRC currently because it's always
present on the export. Let's conditionally export it instead.

DiffTrain build for [e3b7ef32be](https://github.com/facebook/react/commit/e3b7ef32be6a6d01ea050a10a218538e3a75c64f)
2024-11-22 13:24:25 -08:00
poteto 4005e3211d [crud] Fix deps comparison bug (#31599)
Fixes a bug with the experimental `useResourceEffect` hook where we
would compare the wrong deps when there happened to be another kind of
effect preceding the ResourceEffect. To do this correctly we need to add
a pointer to the ResourceEffect's identity on the update.

I also unified the previously separate push effect impls for resource
effects since they are always pushed together as a unit.

DiffTrain build for [c11c9510fa](https://github.com/facebook/react/commit/c11c9510fa14bbd87053685c19bfdfec2f427f49)
2024-11-20 14:02:01 -08:00
poteto 63038b40e0 [crud] Fix copy paste typo (#31588)
Happens to the best of us.

DiffTrain build for [7558ffe84d](https://github.com/facebook/react/commit/7558ffe84df6bab5d701fd90de1c6313f9a1c066)
2024-11-19 14:21:01 -08:00
eps1lon c506d49c28 fix[eslint-plugin-react-hooks]: Fix error when callback argument is an identifier with an as expression (#31119)
DiffTrain build for [eaf2d5c670](https://github.com/facebook/react/commit/eaf2d5c670c84124618977156d81946435922eb3)
2024-11-19 01:43:30 -08:00
poteto 3a9e9ff993 [crud] Basic implementation (#31523)
This PR introduces a new experimental hook `useResourceEffect`, which is
something that we're doing some very early initial tests on.

This may likely not pan out and will be removed or modified if so.
Please do not rely on it as it will break.

DiffTrain build for [047d95e85f](https://github.com/facebook/react/commit/047d95e85f0f0cfa6085b2e355e052a3c34ae24d)
2024-11-18 07:24:14 -08:00
sebmarkbage 215cf146f8 Track separate SuspendedOnAction flag by rethrowing a separate SuspenseActionException sentinel (#31554)
This lets us track separately if something was suspended on an Action
using useActionState rather than suspended on Data.

This approach feels quite bloated and it seems like we'd eventually
might want to read more information about the Promise that suspended and
the context it suspended in. As a more general reason for suspending.

The way useActionState works in combination with the prewarming is quite
unfortunate because 1) it renders blocking to update the isPending flag
whether you use it or not 2) it prewarms and suspends the useActionState
3) then it does another third render to get back into the useActionState
position again.

DiffTrain build for [92c0f5f85f](https://github.com/facebook/react/commit/92c0f5f85fed42024b17bf6595291f9f5d6e8734)
2024-11-15 15:00:42 -08:00
poteto 6aab9387b9 [crud] Rename Effect type (#31557)
Adds a new `Effect` type which for now just points to the `SimpleEffect`
type, in prepartion for later in the stack where we add more.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31557).
* #31523
* __->__ #31557
* #31556
* #31555

DiffTrain build for [053b3cb050](https://github.com/facebook/react/commit/053b3cb0503e26da6d1dfa02b74fa52e30936bd6)
2024-11-15 14:58:52 -08:00
sebmarkbage 06cc3b97bc Log Render Phases that Never Committed (#31548)
This includes:

- `Interrupted Render`: Interrupted Renders (setState or ping at higher
priority)
- `Prewarm`: Suspended Renders outside a Suspense boundary
(RootSuspendedWithDelay/RootSuspendedAtTheShell)
- `Errored Render`: Render that errored somewhere in the tree (Fatal or
Not) (which may or may not be retried and then complete)
- `Teared Render`: Due to useSyncExternalStore not matching (which will
do another sync attempt)

Suspended Commit:

<img width="893" alt="Screenshot 2024-11-14 at 11 47 40 PM"
src="https://github.com/user-attachments/assets/b25a6a8b-a5e9-4d66-b325-57aef4bf9dad">

Errored with a second recovery attempt that also errors:

<img width="976" alt="Screenshot 2024-11-15 at 12 09 06 AM"
src="https://github.com/user-attachments/assets/9ce52cbb-b587-4f1e-8b67-e51d9073ae5b">

DiffTrain build for [3720870a97](https://github.com/facebook/react/commit/3720870a979b48a1ea8776f64a190878b8558f2b)
2024-11-15 09:21:10 -08:00
sebmarkbage fcb79ce20b Unify RootDidNotComplete and RootSuspendedWithDelay exit path (#31547)
Also rename RootDidNotComplete to RootSuspendedAtTheShell since it
specifically means something suspended in the shell during hydration.

DiffTrain build for [8a41d6ceab](https://github.com/facebook/react/commit/8a41d6ceab8af642d8ab9ed04fc744a699f4ac09)
2024-11-14 20:58:53 -08:00
gnoff 9167300ff0 (chore): copy fix in <style> precedence error (#31524)
## Summary

This fixes a typo in the error that gets reported when Float errors
while hoisting a style tag that does not contain both `precedence` and
`href`. There was a typo in _conflict_ and the last part of the sentence
doesn't make sense. I assume it wasn't needed since the message already
suggests moving the style tag to the head manually.

DiffTrain build for [63cde684f5](https://github.com/facebook/react/commit/63cde684f5340b1ca73f6244501aac1c3d2c92a8)
2024-11-14 14:11:25 -08:00
sebmarkbage ed85198c3b Fix Overlapping "message" Bug in Performance Track (#31528)
When you schedule a microtask from render or effect and then call
setState (or ping) from there, the "event" is the event that React
scheduled (which will be a postMessage). The event time of this new
render will be before the last render finished.

We usually clamp these but in this scenario the update doesn't happen
while a render is happening. Causing overlapping events.

Before:

<img width="1229" alt="Screenshot 2024-11-12 at 11 01 30 PM"
src="https://github.com/user-attachments/assets/9652cf3b-b358-453c-b295-1239cbb15952">

Therefore when we finalize a render we need to store the end of the last
render so when we a new update comes in later with an event time earlier
than that, we know to clamp it.

There's also a special case here where when we enter the
`RootDidNotComplete` or `RootSuspendedWithDelay` case we neither leave
the root as in progress nor commit it. Those needs to finalize too.
Really this should be modeled as a suspended track that we haven't added
yet. That's the gap between "Blocked" and "message" below.

After:

<img width="1471" alt="Screenshot 2024-11-13 at 12 31 34 AM"
src="https://github.com/user-attachments/assets/b24f994e-9055-4b10-ad29-ad9b36302ffc">

I also fixed an issue where we may log the same event name multiple
times if we're rendering more than once in the same event. In this case
I just leave a blank trace between the last commit and the next update.

I also adding ignoring of the "message" event at all in these cases when
the event is from React's scheduling itself.

DiffTrain build for [c13986da78](https://github.com/facebook/react/commit/c13986da7866a1a70a73b7ee05c87a9618ce6d03)
2024-11-14 13:42:53 -08:00
acdlite e7777dc2cd Turn on enableSiblingPrerendering in canary (#31541)
In preparation for the next RC, I set this feature flag to true
everywhere. I did not delete the feature flag yet, in case there are yet
more bugs to be discovered.

I also didn't remove the dynamic feature flag from the Meta builds; I'll
let the Meta folks handle that.

DiffTrain build for [988e217670](https://github.com/facebook/react/commit/988e2176702fca9b25113d9a8a3e7e3f484e16f2)
2024-11-14 08:55:26 -08:00
rickhanlonii 8b8e93d2c9 Fix continuation bug (#31434)
## Overview

In `scheduleTaskForRootDuringMicrotask` we clear `root.callbackNode` if
the work loop is [suspended waiting on
data](https://github.com/facebook/react/blob/ac3ca097aeecae8fe3ec7f9b286307a923676518/packages/react-reconciler/src/ReactFiberRootScheduler.js#L338).

But we don't null check `root.callbackNode` before returning a
continuation in `performWorkOnRootViaSchedulerTask` where
`scheduleTaskForRootDuringMicrotask` is synchronously called, causing an
infinite loop when the only thing in the queue is something suspended
waiting on data.

This essentially restores the behavior from here:
https://github.com/facebook/react/pull/26328/files#diff-72ff2175ae3569037f0b16802a41b0cda2b2d66bb97f2bda78ed8445ed487b58L1168

Found by investigating the failures for
https://github.com/facebook/react/pull/31417

## TODO
- add a test

---------

Co-authored-by: Joe Savona <joesavona@fb.com>

DiffTrain build for [b836de613d](https://github.com/facebook/react/commit/b836de613d66ff36574af95cb93ad15fd743d1f4)
2024-11-11 14:32:54 -08:00
jackpope 6a298b24fe Make prerendering always non-blocking with fix (#31452)
We've previously failed to land this change due to some internal apps
seeing infinite render loops due to external store state updates during
render. It turns out that since the `renderWasConcurrent` var was moved
into the do block, the sync render triggered from the external store
check was stuck with a `RootSuspended` `exitStatus`. So this is not
unique to sibling prerendering but more generally related to how we
handle update to a sync external store during render.

We've tested this build against local repros which now render without
crashes. We will try to add a unit test to cover the scenario as well.

---------

Co-authored-by: Andrew Clark <git@andrewclark.io>
Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [989af12f72](https://github.com/facebook/react/commit/989af12f72080c17db03ead91d99b6394a215564)
2024-11-08 09:45:50 -08:00
kassens db36607fa1 [www] set disableLegacyMode to true (#31439)
DiffTrain build for [682a103cde](https://github.com/facebook/react/commit/682a103cde99a3091850d1c27de8846b5d14e803)
2024-11-07 06:12:29 -08:00
kassens d630eddbe9 [string-refs] cleanup string ref code (#31443)
DiffTrain build for [e1378902bb](https://github.com/facebook/react/commit/e1378902bbb322aa1fe1953780f4b2b5f80d26b1)
2024-11-06 11:07:03 -08:00
kassens 9b1ad10d15 [www] set disableStringRefs to true (#31438)
DiffTrain build for [a7b83e7ceb](https://github.com/facebook/react/commit/a7b83e7ceb3e0390e4ad4f9b417f21cb5a0ef17f)
2024-11-06 09:21:54 -08:00
sophiebits 023b265a5a Remove unused lastFullyObservedContext (#31435)
DiffTrain build for [66855b9637](https://github.com/facebook/react/commit/66855b96378daedb1405e83f2365e0d90966ea0e)
2024-11-06 07:42:34 -08:00
kassens 728c4739f8 [string-refs] remove enableLogStringRefsProd flag (#31414)
We no longer need this production logging.

DiffTrain build for [d1f04722d6](https://github.com/facebook/react/commit/d1f04722d617600cc6cd96dcebc1c2ef7affc904)
2024-11-06 06:07:56 -08:00
kassens eed58d445e Remove enableRefAsProp feature flag (#30346)
The flag is fully rolled out.

DiffTrain build for [07aa494432](https://github.com/facebook/react/commit/07aa494432e97f63fca9faf2fad6f76fead31063)
2024-11-04 11:38:26 -08:00
yungsters effe6b514a Fix Ref Lifecycles in Hidden Subtrees (#31379)
## Summary

We're seeing certain situations in React Native development where ref
callbacks in `<Activity mode="hidden">` are sometimes invoked exactly
once with `null` without ever being called with a "current" value.

This violates the contract for refs because refs are expected to always
attach before detach (and to always eventually detach after attach).
This is *particularly* bad for refs that return cleanup functions,
because refs that return cleanup functions expect to never be invoked
with `null`. This bug causes such refs to be invoked with `null`
(because since `safelyAttachRef` was never called, `safelyDetachRef`
thinks the ref does not return a cleanup function and invokes it with
`null`).

This fix makes use of `offscreenSubtreeWasHidden` in
`commitDeletionEffectsOnFiber`, similar to how
https://github.com/facebook/react/commit/ec52a5698e2dfea7050a0b015f0b79abfb2d81b7
did this for `commitDeletionEffectsOnFiber`.

## How did you test this change?

We were able to isolate the repro steps to isolate the React Native
experimental changes. However, the repro steps depend on Fast Refresh.

```
function callbackRef(current) {
  // Called once with `current` as null, upon triggering Fast Refresh.
}

<Activity mode="hidden">
  <View ref={callbackRef} />;
</Activity>
```

Ideally, we would have a unit test that verifies this behavior without
Fast Refresh. (We have evidence that this bug occurs without Fast
Refresh in real product implementations. However, we have not
successfully deduced the root cause, yet.)

This PR currently includes a unit test that reproduces the Fast Refresh
scenario, which is also demonstrated in this CodeSandbox:
https://codesandbox.io/p/sandbox/hungry-darkness-33wxy7

Verified unit tests pass:

```
$ yarn
$ yarn test
# Run with `-r=www-classic` for `enableScopeAPI` tests.
$ yarn test -r=www-classic
```

Verified on the internal React Native development branch that the bug no
longer repros.

---------

Co-authored-by: Rick Hanlon <rickhanlonii@fb.com>

DiffTrain build for [ea3ac58669](https://github.com/facebook/react/commit/ea3ac586693014e882655728fc8396ecb1d6cf6e)
2024-10-31 13:32:06 -07:00
sebmarkbage 84a3f07e89 Capture the source and not just the stack on first seen error (#31367)
Otherwise we can't capture the owner stack at the right location when
there's a rethrow.

DiffTrain build for [0bc3074873](https://github.com/facebook/react/commit/0bc30748730063e561d87a24a4617526fdd38349)
2024-10-28 14:07:07 -07:00
jackpope 990f566106 Revert "[Re-land] Make prerendering always non-blocking (#31268)" (#31355)
This reverts commit 6c4bbc7832.

It looked like the bug we found on the original land was related to
broken product code. But through landing #31268 we found additional bugs
internally. Since disabling the feature flag does not fix the bugs, we
have to revert again to unblock the sync. We can continue to debug with
our internal build.

DiffTrain build for [cae764ce81](https://github.com/facebook/react/commit/cae764ce81b1bd6c418e9e23651794b6b09208e8)
2024-10-25 09:24:34 -07:00
mofeiZ a758eaca4f react-hooks/rules-of-hooks: Add support for do/while loops (#28714)
<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn test --debug --watch TestName`,
open `chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

Currently, `react-hooks/rules-of-hooks` does not support `do/while`
loops - I've also reported this in
https://github.com/facebook/react/issues/28713.

This PR takes a stab at adding support for `do/while` by following the
same logic we already have for detecting `while` loops.

After this PR, any hooks called inside a `do/while` loop will be
considered invalid.

We're also adding some unit tests to confirm that the behavior is
working as expected.

Fixes #28713.

## How did you test this change?

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->

I've added unit tests that cover the case and verified that they pass by
running:

```
yarn test packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js --watch
```

I've also verified that the rest of the tests continue to pass by
running:

```
yarn test
```

and

```
yarn test --prod
```

DiffTrain build for [9daabc0bf9](https://github.com/facebook/react/commit/9daabc0bf97805be23f6131be4d84d063a3ff446)
2024-10-22 13:15:33 -07:00
sebmarkbage 48dd4dd46c Audit try/finally around console patching (#31286)
Otherwise if something errors they can be left patched.

[Review without
whitespace](https://github.com/facebook/react/pull/31286/files?w=1)

DiffTrain build for [b8ae38f88b](https://github.com/facebook/react/commit/b8ae38f88b70f8a0ea96421a4355266aafefee7f)
2024-10-18 09:14:24 -07:00
jackpope 7b4965f000 [Re-land] Make prerendering always non-blocking (#31268)
Follows https://github.com/facebook/react/pull/31238

___

This is a partial re-land of
https://github.com/facebook/react/pull/31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: https://github.com/facebook/react/pull/31056
Original Commit:
https://github.com/facebook/react/pull/31056/commits/4c71025d8d1bd46344ad793e7ed3049d24f7395a
Revert PR: https://github.com/facebook/react/pull/31080

Commit description:

> When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.
>
> This happens automatically when there's a Suspense boundary, because
we immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [6c4bbc7832](https://github.com/facebook/react/commit/6c4bbc783286bf6eebd9927cb52e8fec5ad4dd74)
2024-10-15 13:55:41 -07:00
jackpope d3a3f5f05b [Re-land] Make prerendering always non-blocking: Add missing feature flag checks (#31238)
This is a partial re-land of
https://github.com/facebook/react/pull/31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: https://github.com/facebook/react/pull/31056
Original Commit:
https://github.com/facebook/react/pull/31056/commits/2a9fb445d98b60a97f3642cec2ff22469727e0c7
Revert PR: https://github.com/facebook/react/pull/31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4589](https://github.com/facebook/react/commit/13411e4589f3d999727c5322781e2dd7bef3b256)
2024-10-14 11:19:46 -07:00
kassens c1210a151d [string-refs] make disableStringRefs a dynamic www flag (#31175)
DiffTrain build for [75dd053b5e](https://github.com/facebook/react/commit/75dd053b5e83e8ae20e9f771bca7b95dba4ff881)
2024-10-14 07:21:37 -07:00
kassens 0ccec156d7 [string-refs] log string ref from prod (#31161)
If passed as a feature flag, this calls the configured function when a
string ref is used even from prod code to find the last usages.

DiffTrain build for [5636fad840](https://github.com/facebook/react/commit/5636fad840942cfea80301d91e931a50c6370d19)
2024-10-10 15:20:27 -07:00
poteto 877636d7e9 [rcr] Re-export useMemoCache in top level React namespace (#31139)
In order to support using the compiler on versions of React prior to 19,
we need the ability to statically import `c` (aka useMemoCache) or
fallback to a polyfill supplied by `react-compiler-runtime` (note: this
is a separate npm package, not to be confused with
`react/compiler-runtime`, which is currently a part of react).

To do this we first need to re-export `useMemoCache` under the top level
React namespace again, which is additive and thus non-breaking. Doing so
allows `react-compiler-runtime` to statically either re-export
`React.__COMPILER_RUNTIME.c` or supply a polyfill, without the need for
a dynamic import which is finicky to support due to returning a promise.

In later PRs I will remove `react/compiler-runtime` and update the
compiler to emit imports to `react-compiler-runtime` instead.

DiffTrain build for [b78a7f2f35](https://github.com/facebook/react/commit/b78a7f2f35e554a8647c3262d7f392e68d06febc)
2024-10-07 13:32:14 -07:00
jackpope 56bda35dd1 Disable infinite render loop detection (#31088)
We're seeing issues with this feature internally including bugs with
sibling prerendering and errors that are difficult for developers to
action on. We'll turn off the feature for the time being until we can
improve the stability and ergonomics.

This PR does two things:
- Turn off `enableInfiniteLoopDetection` everywhere while leaving it as
a variant on www so we can do further experimentation.
- Revert https://github.com/facebook/react/pull/31061 which was a
temporary change for debugging. This brings the feature back to
baseline.

DiffTrain build for [d8c90fa48d](https://github.com/facebook/react/commit/d8c90fa48d3addefe4b805ec56a3c65e4ee39127)
2024-10-01 08:08:39 -07:00
gnoff e2de2adf75 [Fizz] Start initial work immediately (#31079)
In a recent update we make Flight start working immediately rather than
waitin for a new task. This commit updates fizz to have similar
mechanics. We start the render in the currently running task but we do
so in a microtask to avoid reentrancy. This aligns Fizz with Flight.

ref: https://github.com/facebook/react/pull/30961

DiffTrain build for [67fee58b1f](https://github.com/facebook/react/commit/67fee58b1f72754cc77488c40c44e786572ef954)
2024-09-26 13:59:31 -07:00
poteto b113f683d4 No commit message
DiffTrain build for [67fee58b1f](https://github.com/facebook/react/commit/67fee58b1f72754cc77488c40c44e786572ef954)
2024-09-26 13:58:44 -07:00
eps1lon 5f9db2fb7f [Fiber] Fix missing render times when we cancel a pending commit (#31065)
DiffTrain build for [778e1ed2e5](https://github.com/facebook/react/commit/778e1ed2e5ec22d4bac48e14167d3b4a6b28e8b8)
2024-09-25 15:28:49 -07:00
acdlite 9b61452a2a Make prerendering always non-blocking (#31056)
When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.

This happens automatically when there's a Suspense boundary, because we
immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

DiffTrain build for [0f1856c49f](https://github.com/facebook/react/commit/0f1856c49febe96923e469f98c0b123130ea015c)
2024-09-25 13:40:14 -07:00
acdliteandpoteto fd6224b6ea Unify perform{Sync,Concurrent}WorkOnRoot implementation (#31029)
Over time the behavior of these two paths has converged to be
essentially the same. So this merges them back into one function. This
should save some code size and also make it harder for the behavior to
accidentally diverge. (For the same reason, rolling out this change
might expose some areas where we had already accidentally diverged.)

DiffTrain build for [3c7667a694](https://github.com/facebook/react/commit/3c7667a694face1827356a7c90ee6f86a9c0baa0)
2024-09-25 12:41:50 -07:00
jackpope f1486377de Increase nested update limit to 100 (#31061)
We're seeing the limit hit in some tests after enabling sibling
prerendering. Let's bump the limit so we can run more tests and gather
more signal on the changes. When we understand the scope of the problem
we can determine whether we need to change how the updates are counted
in prerenders and/or fix specific areas of product code.

DiffTrain build for [f9ebd85a19](https://github.com/facebook/react/commit/f9ebd85a196948be17efdd6774b4d0464b3b1f53)
2024-09-25 08:59:35 -07:00
poteto 97355e033b DiffTrain build for [](https://github.com/facebook/react/commit/) 2024-09-24 09:00:02 -07:00
sebmarkbage d21a7619e0 [Fiber] Log the Render/Commit phases and the gaps in between (#31016)
A slight behavior change here too is that I now mark the start of the
commit phase before the BeforeMutationEffect phase. This affects
`<Profiler>` too.

The named sequences are as follows:

Render -> Suspended or Throttled -> Commit -> Waiting for Paint ->
Remaining Effects

The Suspended phase is only logged if we delay the Commit due to CSS /
images.

The Throttled phase is only logged if we delay the commit due to the
Suspense throttling timer.

<img width="1246" alt="Screenshot 2024-09-20 at 9 14 23 PM"
src="https://github.com/user-attachments/assets/8d01f444-bb85-472b-9b42-6157d92c81b4">

I don't yet log render phases that don't complete. I think I also need
to special case renders that or don't commit after being suspended.

DiffTrain build for [4e9540e3c2](https://github.com/facebook/react/commit/4e9540e3c2a8f9ae56318b967939c99b3a815190)
2024-09-23 11:17:21 -07:00