Skip to content

Commit a94838d

Browse files
authoredApr 23, 2024··
Remove automatic fetch cache instrumentation (#28896)
This removes the automatic patching of the global `fetch` function in Server Components environments to dedupe requests using `React.cache`, a behavior that some RSC framework maintainers have objected to. We may revisit this decision in the future, but for now it's not worth the controversy. Frameworks that have already shipped this behavior, like Next.js, can reimplement it in userspace. I considered keeping the implementation in the codebase and disabling it by setting `enableFetchInstrumentation` to `false` everywhere, but since that also disables the tests, it doesn't seem worth it because without test coverage the behavior is likely to drift regardless. We can just revert this PR later if desired.
1 parent d4e78c4 commit a94838d

12 files changed

+0
-459
lines changed
 

‎packages/react/src/ReactFetch.js

-141
This file was deleted.

‎packages/react/src/ReactServer.experimental.js

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

10-
// Patch fetch
11-
import './ReactFetch';
12-
1310
export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';
1411

1512
import {forEach, map, count, toArray, only} from './ReactChildren';

‎packages/react/src/ReactServer.js

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

10-
// Patch fetch
11-
import './ReactFetch';
12-
1310
export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';
1411

1512
import {forEach, map, count, toArray, only} from './ReactChildren';

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

-215
This file was deleted.

‎packages/react/src/__tests__/ReactFetchEdge-test.js

-90
This file was deleted.

‎packages/shared/ReactFeatureFlags.js

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export const enableLegacyFBSupport = false;
7878

7979
export const enableCache = true;
8080
export const enableLegacyCache = __EXPERIMENTAL__;
81-
export const enableFetchInstrumentation = true;
8281

8382
export const enableBinaryFlight = __EXPERIMENTAL__;
8483
export const enableFlightReadableStream = __EXPERIMENTAL__;

‎packages/shared/forks/ReactFeatureFlags.native-fb.js

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
4343
export const enableUpdaterTracking = __PROFILE__;
4444
export const enableCache = true;
4545
export const enableLegacyCache = false;
46-
export const enableFetchInstrumentation = false;
4746
export const enableBinaryFlight = true;
4847
export const enableFlightReadableStream = true;
4948
export const enableAsyncIterableChildren = false;

‎packages/shared/forks/ReactFeatureFlags.native-oss.js

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export const enableDebugTracing = false;
7373
export const enableAsyncDebugInfo = false;
7474
export const enableSchedulingProfiler = __PROFILE__;
7575
export const enableLegacyCache = false;
76-
export const enableFetchInstrumentation = false;
7776
export const enablePostpone = false;
7877
export const disableCommentsAsDOMContainers = true;
7978
export const disableInputAttributeSyncing = false;

‎packages/shared/forks/ReactFeatureFlags.test-renderer.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2020
export const enableUpdaterTracking = false;
2121
export const enableCache = true;
2222
export const enableLegacyCache = __EXPERIMENTAL__;
23-
export const enableFetchInstrumentation = true;
2423
export const enableBinaryFlight = true;
2524
export const enableFlightReadableStream = true;
2625
export const enableAsyncIterableChildren = false;

‎packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2020
export const enableUpdaterTracking = false;
2121
export const enableCache = true;
2222
export const enableLegacyCache = false;
23-
export const enableFetchInstrumentation = false;
2423
export const enableBinaryFlight = true;
2524
export const enableFlightReadableStream = true;
2625
export const enableAsyncIterableChildren = false;

‎packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const enableProfilerNestedUpdatePhase = __PROFILE__;
2020
export const enableUpdaterTracking = false;
2121
export const enableCache = true;
2222
export const enableLegacyCache = true;
23-
export const enableFetchInstrumentation = false;
2423
export const enableBinaryFlight = true;
2524
export const enableFlightReadableStream = true;
2625
export const enableAsyncIterableChildren = false;

‎packages/shared/forks/ReactFeatureFlags.www.js

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export const renameElementSymbol = false;
6969

7070
export const enableCache = true;
7171
export const enableLegacyCache = true;
72-
export const enableFetchInstrumentation = false;
7372

7473
export const enableBinaryFlight = false;
7574
export const enableFlightReadableStream = false;

0 commit comments

Comments
 (0)
Please sign in to comment.