@samitouri / QOS-React-2 / commits / caa84c8da0

Revert fetch instrumentation to only RSC (#25540)

Revert fetch instrumentation so that it only affects RSC by applying it only in the react-server condition of "react". This helps make the rollout a little smoother because these affects existing libraries that fetch during client components, and then gets forever cached. We need to implement the GC first. I haven't fully implemented the SSR part anyway. The main problem that we discovered is that `"react"` and `"react/react.shared-subset"` have separate dispatchers in an environment that runs both Fizz and Flight. That's intentional and sometimes a feature. However, in this case it means that we instrument fetch twice and when you run Flight inside Fizz, that fetch goes into both caches when it's supposed to only see the inner one. I'm not sure how to solve that atm.

Sebastian Markbåge committed Oct 22, 2022 at 22:58 UTC caa84c8da0aed390ec25783e577d91711dfd6bcc
3 files changed +6 -3
packages/react/src/React.js
-3
@@ -71,9 +71,6 @@ import ReactSharedInternals from './ReactSharedInternals';
71 import {startTransition} from './ReactStartTransition';
72 import {act} from './ReactAct';
73
74 -// Patch fetch
75 -import './ReactFetch';
76 -
74 // TODO: Move this branching into the other module instead and just re-export.
75 const createElement: any = __DEV__
76 ? createElementWithValidation
packages/react/src/ReactSharedSubset.experimental.js
+3
@@ -7,6 +7,9 @@
7 * @flow
8 */
9
10 +// Patch fetch
11 +import './ReactFetch';
12 +
13 export {
14 __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
15 Children,
packages/react/src/__tests__/ReactFetch-test.js
+3
@@ -41,6 +41,9 @@ describe('ReactFetch', () => {
41 fetchCount = 0;
42 global.fetch = fetchMock;
43
44 + if (gate(flags => flags.experimental && !flags.www)) {
45 + jest.mock('react', () => require('react/react.shared-subset'));
46 + }
47 React = require('react');
48 ReactServerDOMServer = require('react-server-dom-webpack/server.browser');
49 ReactServerDOMClient = require('react-server-dom-webpack/client');