Skip to content

Commit

Permalink
Remove automatic fetch cache instrumentation (facebook#28896)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite committed Apr 23, 2024
1 parent d4e78c4 commit a94838d
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 459 deletions.
141 changes: 0 additions & 141 deletions packages/react/src/ReactFetch.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/react/src/ReactServer.experimental.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* @flow
*/

// Patch fetch
import './ReactFetch';

export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';

import {forEach, map, count, toArray, only} from './ReactChildren';
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/ReactServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
* @flow
*/

// Patch fetch
import './ReactFetch';

export {default as __SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE} from './ReactSharedInternalsServer';

import {forEach, map, count, toArray, only} from './ReactChildren';
Expand Down
215 changes: 0 additions & 215 deletions packages/react/src/__tests__/ReactFetch-test.js

This file was deleted.

Loading

0 comments on commit a94838d

Please sign in to comment.