Skip to content

Add custom fetch injection to FetchHttpClient for Next.js caching #5101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ethanzrd
Copy link

Automated Changes by SimulateDev

Setup

Task

Add custom fetch injection capability to FetchHttpClient to enable Next.js caching support while maintaining backward compatibility.

Coding agents used

  1. cursor with claude-4-sonnet as Planner
  2. cursor with claude-4-sonnet as Coder
  3. cursor with claude-4-sonnet as Tester

Execution time

⏱️ 13m 32.2s


Summary

This PR addresses issue #4922 by adding the ability to inject a custom fetch implementation into the FetchHttpClient. The new layerWithFetch function allows developers to provide their own fetch implementation, enabling the use of Next.js's patched fetch and its caching capabilities. The changes maintain full backward compatibility while providing a clean API for custom fetch injection. Implementation was completed using Cursor IDE with Claude-4-Sonnet across planning, coding, and testing phases.

What changed?

  • Added layerWithFetch function to packages/platform/src/FetchHttpClient.ts
  • Created internal layerWithFetch export in packages/platform/src/internal/fetchHttpClient.ts
  • Updated documentation and usage examples for custom fetch injection
  • Maintained backward compatibility with existing layer export
  • Enhanced support for Next.js caching through custom fetch implementation

Review Instructions

Please carefully review all changes before merging. While AI agents are powerful, human oversight is always recommended.


Generated by SimulateDev, the AI coding agents collaboration platform.

- Add layerWithFetch function to allow custom fetch implementation
- Enable Next.js caching support through fetch injection
- Maintain backward compatibility with existing layer export
- Update documentation with usage examples for custom fetch

Resolves issue Effect-TS#4922 where FetchHttpClient couldn't utilize Next.js's
patched fetch for caching capabilities.
@ethanzrd ethanzrd requested a review from tim-smart as a code owner June 25, 2025 10:23
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Jun 25, 2025
Copy link

changeset-bot bot commented Jun 25, 2025

⚠️ No Changeset found

Latest commit: 223058b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@tim-smart
Copy link
Contributor

You can already inject a custom fetch function: https://github.com/Effect-TS/effect/tree/main/packages/platform#injecting-fetch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

2 participants