Skip to content

Commit caa84c8

Browse files
authored
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.
1 parent 0c11baa commit caa84c8

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/react/src/React.js

-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ import ReactSharedInternals from './ReactSharedInternals';
7171
import {startTransition} from './ReactStartTransition';
7272
import {act} from './ReactAct';
7373

74-
// Patch fetch
75-
import './ReactFetch';
76-
7774
// TODO: Move this branching into the other module instead and just re-export.
7875
const createElement: any = __DEV__
7976
? createElementWithValidation

packages/react/src/ReactSharedSubset.experimental.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
* @flow
88
*/
99

10+
// Patch fetch
11+
import './ReactFetch';
12+
1013
export {
1114
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
1215
Children,

packages/react/src/__tests__/ReactFetch-test.js

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ describe('ReactFetch', () => {
4141
fetchCount = 0;
4242
global.fetch = fetchMock;
4343

44+
if (gate(flags => flags.experimental && !flags.www)) {
45+
jest.mock('react', () => require('react/react.shared-subset'));
46+
}
4447
React = require('react');
4548
ReactServerDOMServer = require('react-server-dom-webpack/server.browser');
4649
ReactServerDOMClient = require('react-server-dom-webpack/client');

0 commit comments

Comments
 (0)