effect icon indicating copy to clipboard operation
effect copied to clipboard

Add custom fetch injection to FetchHttpClient for Next.js caching

Open ethanzrd opened this issue 6 months ago • 1 comments

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.

ethanzrd avatar Jun 25 '25 10:06 ethanzrd

⚠️ No Changeset found

Latest commit: 223058b4b76f88047d6384b58b86dfab9a0c83b1

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

changeset-bot[bot] avatar Jun 25 '25 10:06 changeset-bot[bot]

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

tim-smart avatar Jun 25 '25 22:06 tim-smart