Skip to content

feat(effect): update integration to Effect V4#1603

Merged
dinwwwh merged 8 commits into
middleapi:mainfrom
LarsLrn:feature/support-effect-v4
Jun 25, 2026
Merged

feat(effect): update integration to Effect V4#1603
dinwwwh merged 8 commits into
middleapi:mainfrom
LarsLrn:feature/support-effect-v4

Conversation

@LarsLrn

@LarsLrn LarsLrn commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Updated @orpc/experimental-effect to support Effect V4.

Summary by CodeRabbit

  • New Features
    • Expanded Effect integration support for newer schema/service APIs, including updated input/output schema handling and improved handler typing.
    • Enhanced JSON Schema generation for Effect schemas.
  • Bug Fixes
    • Improved runPromise interruption behavior to report consistent abort errors (including honoring a provided abort reason).
  • Documentation
    • Refreshed Effect integration examples to match current Effect API patterns.
  • Tests
    • Updated and extended type and runtime tests around the new schema/abort behavior.
  • Chores
    • Pinned Effect beta dependency updates and adjusted workspace release/build settings.

Copilot AI review requested due to automatic review settings June 24, 2026 11:55
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 24, 2026
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orpc Ready Ready Preview, Comment Jun 25, 2026 1:55pm

@dosubot dosubot Bot added dependencies Pull requests that update a dependency file enhancement New feature or request javascript Pull requests that update javascript code labels Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00971e8f-b916-464c-8478-723fc57b9cea

📥 Commits

Reviewing files that changed from the base of the PR and between 5bba25c and dc3dc9f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/content/package.json
  • packages/effect/package.json
  • packages/effect/src/converter.ts
  • packages/effect/src/extensions/input-output.ts
  • packages/effect/src/schema.ts
  • pnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (1)
  • pnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/effect/src/schema.ts
  • packages/effect/package.json
  • packages/effect/src/converter.ts
  • packages/effect/src/extensions/input-output.ts

📝 Walkthrough

Walkthrough

Updates the Effect integration package, related tests, docs, and workspace constraints for the Effect v4 beta API surface. The changes cover schema conversion types, yield typing, runtime error handling, service declarations, and example code.

Changes

Effect v4 Upgrade

Layer / File(s) Summary
Dependency and workspace constraints
apps/content/package.json, packages/effect/package.json, pnpm-workspace.yaml
Updates effect dependency constraints in the content app and Effect package, and adjusts workspace release-age and build settings.
Schema ConstraintDecoder migration
packages/effect/src/schema.ts, packages/effect/src/converter.ts, packages/effect/src/extensions/input-output.ts, packages/effect/src/extensions/input-output.test-d.ts, packages/effect/src/converter.test.ts
Replaces Effect schema conversion and input/output typings with ConstraintDecoder-based types, adds runtime detection for Effect constraint decoders, updates standard schema conversion helpers, and adjusts the related tests.
YieldWrap removal from handler and effect extensions
packages/effect/src/extensions/effect.ts, packages/effect/src/handler.ts
Removes YieldWrap from Effect yield typing across builder overloads and handler inference, and changes the ORPC error helper to use Effect.catch.
Runtime Cause extraction rewrite
packages/effect/src/runtime.ts, packages/effect/src/runtime.test.ts
Reworks runPromise error handling to inline interruption detection, abort behavior, and cause squashing, and updates the related runtime assertions.
Service declaration and documentation updates
packages/effect/src/handler.test-d.ts, packages/effect/src/handler.test.ts, apps/content/docs/integrations/effect.md
Updates handler service declarations and integration docs for the Effect service, wrap, and schema API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size:XL

Poem

🐇 I hop through v4 with a twitchy nose,
New schemas bloom where old code goes.
CatchCause hums and Cause.squash sings,
While service classes sprout fresh springs.
A carrot toast to beta light — 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: updating the Effect integration for Effect V4.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the project's integration with the effect library to version 4 (beta), adapting the codebase to several API changes including replacing Context.Tag with Context.Service, migrating to standard schema methods, and removing YieldWrap from type signatures. The review feedback suggests leveraging the predicate form of Effect.catch to handle ORPCErrors more cleanly, and restoring the use of FiberId.threadName to prevent potential stringification issues when reporting interrupted fibers.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/effect/src/handler.ts
Comment thread packages/effect/src/runtime.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/effect/package.json (1)

54-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Beta peer range admits breaking betas.

>=4.0.0-beta.86 <5 will satisfy any later Effect v4 beta/RC, but Effect v4 is pre-stable and beta-to-beta changes can break the APIs this package now relies on (toStandardSchemaV1, toStandardJSONSchemaV1, ConstraintDecoder). Consider an upper bound on the beta line (e.g. >=4.0.0-beta.86 <4.0.0-rc / pinning to a tested beta band) until v4 stabilizes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/effect/package.json` at line 54, The peer dependency range for the
Effect package is too broad and can admit later breaking beta/RC releases.
Tighten the version constraint in the package manifest for the effect dependency
used by the package so it stays within a tested v4 beta band or caps before
stable/RC releases, and keep the range aligned with the APIs relied on here such
as toStandardSchemaV1, toStandardJSONSchemaV1, and ConstraintDecoder.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/effect/package.json`:
- Line 54: The peer dependency range for the Effect package is too broad and can
admit later breaking beta/RC releases. Tighten the version constraint in the
package manifest for the effect dependency used by the package so it stays
within a tested v4 beta band or caps before stable/RC releases, and keep the
range aligned with the APIs relied on here such as toStandardSchemaV1,
toStandardJSONSchemaV1, and ConstraintDecoder.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77487a3e-4298-4095-8c3f-1c2f6adbfce3

📥 Commits

Reviewing files that changed from the base of the PR and between 94acd87 and 56532bc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • apps/content/docs/integrations/effect.md
  • apps/content/package.json
  • packages/effect/package.json
  • packages/effect/src/converter.ts
  • packages/effect/src/extensions/effect.ts
  • packages/effect/src/extensions/input-output.test-d.ts
  • packages/effect/src/extensions/input-output.ts
  • packages/effect/src/handler.test-d.ts
  • packages/effect/src/handler.test.ts
  • packages/effect/src/handler.ts
  • packages/effect/src/runtime.ts
  • packages/effect/src/schema.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — migration of @orpc/experimental-effect and its docs from Effect v3 to Effect v4.

  • Bumped effect range to >=4.0.0-beta.86 <5 in packages/effect and apps/content.
  • Migrated schema conversion APIs to Schema.toStandardSchemaV1 and Schema.toStandardJSONSchemaV1.
  • Updated input/output overloads to use Schema.ConstraintDecoder<any, never> and map its Encoded/Type members.
  • Replaced YieldWrap with direct Effect.Effect yields and updated error handling (Effect.catch, Effect.catchCause, Cause.squash, Context.Service).
  • Updated Effect examples in apps/content/docs/integrations/effect.md.

Pullfrog  | View workflow run | Using openrouter/moonshotai/kimi-k2.7-code (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/effect/package.json`:
- Line 54: The peer dependency range for effect is too open and can resolve to
v5 unexpectedly; tighten the peerDependencies.effect constraint in package.json
to keep this package on the v4-beta contract. Update the existing effect version
range to include an upper bound below 5 while preserving the current minimum,
and ensure the change is applied in the package.json peerDependencies entry for
effect.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 750f33a3-c665-4bec-bef0-9f4c22f1adad

📥 Commits

Reviewing files that changed from the base of the PR and between 56532bc and 75030d6.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/content/package.json
  • packages/effect/package.json
  • packages/effect/src/runtime.test.ts
  • packages/effect/src/runtime.ts
  • packages/effect/src/schema.ts
  • pnpm-workspace.yaml
✅ Files skipped from review due to trivial changes (1)
  • pnpm-workspace.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/effect/src/schema.ts

Comment thread packages/effect/package.json Outdated
Comment thread packages/effect/src/converter.ts Outdated
convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean] {
const effectSchema = schema as unknown as EffectSchema.Schema<any, any> & AnySchema
const jsonSchema = JSONSchema.make(effectSchema, { target: 'jsonSchema2020-12' })
const effectSchema = schema as EffectSchema.Unknown & AnySchema

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this approach. It seems Effect doesn't support draft-2020-12, so there's no built-in way to handle it. Also, the draft-2020-12 type here comes only from the standard JSON Schema specification might not work or ignored by effect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the Effect code, and I think they do actually support draft-2020-12.

...jsonSchema.input({ target: "draft-2020-12" }) calls toBaseStandardJSONSchemaV1, which first calls toJsonSchemaDocument. That function returns JsonSchema.Document<"draft-2020-12"> and sets dialect: "draft-2020-12". For the "draft-2020-12" target, Effect returns that schema directly and moves definitions to $defs.

That said, I agree that it isn't ideal and relies too much on Effect internals. Instead, it now only calls Schema.toStandardJSONSchemaV1 to attach Effect’s Standard JSON Schema support, then delegates the actual JSON Schema generation to oRPC's existing StandardJsonSchemaConverter.

I also added a test with Schema.NumberFromString to verify that input/output conversion direction is preserved through that path.

Comment thread packages/effect/src/runtime.ts
@pkg-pr-new

pkg-pr-new Bot commented Jun 25, 2026

Copy link
Copy Markdown
@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1603

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1603

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1603

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@1603

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@1603

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1603

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1603

@orpc/next

npm i https://pkg.pr.new/@orpc/next@1603

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1603

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@1603

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@1603

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@1603

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@1603

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1603

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1603

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1603

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1603

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1603

commit: dc3dc9f

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

Pullfrog  | Fix it ➔View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@pullfrog

pullfrog Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

The Effect peer dependency range is now unbounded and will admit incompatible future major versions.

Reviewed changes — since the prior review, the PR pinned Effect to 4.0.0-beta.88 for development and simplified runPromise error extraction.

  • Pinned effect to exact 4.0.0-beta.88 in packages/effect dev dependency and apps/content.
  • Widened the effect peer dependency to >=4.0.0-beta.88 without an upper bound.
  • Simplified runPromise by removing extractErrorFromCause and using Cause.hasInterruptsOnly plus Cause.squash.
  • Added signal-reason propagation and generic AbortError handling for interruption-only failures.
  • Excluded effect@4.0.0-beta.88 from minimum release age and disabled msgpackr-extract builds in pnpm-workspace.yaml.

⚠️ Peer dependency range admits incompatible future majors

packages/effect/package.json:54 now declares "effect": ">=4.0.0-beta.88". The prior range was >=4.0.0-beta.86 <5, so the <5 upper bound has been dropped. Consumers can satisfy this peer dependency with Effect v5 or any later breaking release, even though the package is built and tested against Effect v4 beta.

Suggested fix: restore the upper bound, e.g. "effect": ">=4.0.0-beta.88 <5".

ℹ️ Public extractErrorFromCause helper removed

The helper was previously exported through @orpc/experimental-effect (via index.ts re-exporting ./runtime) and is no longer part of the public surface. Worth a release-note callout since it's a breaking change for the experimental package.

ℹ️ Nitpicks

  • packages/effect/src/runtime.test.ts:84 — grammar typo in test description ("throws a empty Error" → "throws an empty Error").

Note: the Pullfrog review tool encountered a session deduplication issue while submitting this review, so the findings are posted as a standalone comment.

Pullfrog  | View workflow run | via Pullfrog | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

* Use ORPCs own `StandardJsonSchemaConverter` instead of effect's built-ins.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/effect/src/converter.ts`:
- Around line 8-16: The JSON conversion path in converter.ts is using a
non-existent EffectSchema.toStandardJSONSchemaV1 API and an incorrect cast to
EffectSchema.Constraint. Update convert(...) to work with the already validated
standard schema from schema['~standard'] and use the proper Effect Schema JSON
conversion API, such as Schema.toJSONSchema or Schema.standardSchemaV1, then
pass that result to standardJsonSchemaConverter.convert. Keep the fix localized
to the condition(...) / convert(...) logic so the converter handles AnySchema
consistently without the invalid Constraint cast.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cda74b65-f836-4a76-8267-087c60efd57d

📥 Commits

Reviewing files that changed from the base of the PR and between 75030d6 and 5bba25c.

📒 Files selected for processing (2)
  • packages/effect/src/converter.test.ts
  • packages/effect/src/converter.ts

Comment thread packages/effect/src/converter.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — refactored Effect JSON-schema conversion to delegate input/output generation and optional detection to @orpc/json-schema's shared converter.

  • Replaced the inline JSONSchema.make + manual optional check in EffectSchemaToJsonSchemaConverter with a call to StandardJsonSchemaConverter.convert, reusing the same logic that handles other standard-schema libraries.
  • Added tests verifying effect's standard-JSON-schema input/output generators and that conversion survives a throwing ~standard.validate.

Pullfrog  | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 25, 2026
@dinwwwh dinwwwh merged commit 7e282f8 into middleapi:main Jun 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request javascript Pull requests that update javascript code lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants