Repository navigation
docs(effect): fix Effect v4 samples and add runtime notes - #2260
Conversation
… and runtimes - OpenTelemetry: use `OtelTracer.layerGlobal` from `@effect/opentelemetry` 4.x (the v3 `Tracer` module no longer exists) and build it once with a `ManagedRuntime` passed through `effect/context`, instead of `Effect.provide(Layer)` in `effect/wrap`, which rebuilt the layer for every effectful middleware and handler on every request. - Effect Services: add "Providing Services with Layers" (ManagedRuntime, `runtime.context()` per request, shared memo map, `dispose()` on shutdown). - Follow Effect's style guide: `return yield* Effect.fail(...)`, `Clock.currentTimeMillis` instead of `Date.now()` in `Effect.sync`. - Add notes on request interruption and finalizers, testing with `@effect/vitest`, mapping `Schema.TaggedError` to `errors.X()` with `Effect.catchTags`, `.effect` on `implement(contract)`, Next.js `unstable_rethrow` in defect handlers, and the sync scheduler on Cloudflare Workers. - JSDoc: make the `effect/context` and `effect/wrap` examples type-check and match the docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6ABJnL9M1jjzNoYvMd3QK
Drop repeated fetch handlers and Effect-only setup from the samples, and fold Testing into a tip under "Providing Services with Layers". Trim the JSDoc to one example per field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6ABJnL9M1jjzNoYvMd3QK
`effect/context` accepts any Effect context, so building one from a ManagedRuntime needs no section of its own. Keep the warning against providing layers in `effect/wrap`, and point the OpenTelemetry and Cloudflare notes at `effect/context` instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6ABJnL9M1jjzNoYvMd3QK
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N6ABJnL9M1jjzNoYvMd3QK
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | 57b95b2 | Commit Preview URL Branch Preview URL |
Oct 17 2026, 02:33 AM |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/experimental-msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — full diff (5 commits), docs-only: the Effect integration guide and the WithEffectContext JSDoc.
- OpenTelemetry sample (v4 fix): replaced the non-existent
Tracerimport withOtelTracer.layerGlobalon the runtime layer, passed aseffect/context. Verified against@effect/opentelemetry@4.0.2—OtelTracer.layerGlobalinstalls the EffectTracer.TracervialayerGlobalTracerand needs noResourcelayer; the package root exports noTracernamespace. effect/wrapguidance: new warning plus JSDoc note that the hook runs permiddlewareGen/handlerGen(confirmed atpackages/effect/src/handler.ts:48andpackages/effect/src/middleware.ts:73), so layers should be provided viaeffect/context.- New notes:
.effectonimplement(contract)(backed byProcedureImplementer.prototype.effect), Interruption (Effect.scopedforacquireRelease), Cloudflare Workers (Scheduler.MixedScheduler('sync')+ module-scope runtime), Next.js (unstable_rethrowinsidecatchCause). - Style:
return yield* Effect.fail(...),Clock.currentTimeMillisinmiddlewareGen,Effect.sync(() => Math.random()). - JSDoc:
effect/contextandeffect/wrapexamples now type-check;@seebacklink titles match the checker's expected format and the#error-handlinganchor resolves.
Every changed API usage was validated against the installed effect@4.0.2 and the published @effect/opentelemetry@4.0.2 source (Context.Service class form, Context.empty()/Context.add currying, Effect.withSpan data-last, Clock.currentTimeMillis, Scheduler.MixedScheduler('sync'), ManagedRuntime.context() returning a Promise). No stale references to the removed Tracer import remain.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Merging this PR will not alter performance
|
Resolve conflicts with #2260: keep main's OpenTelemetry, Cloudflare Workers and layer warning docs, plus its typed effect/context JSDoc example; keep this branch's Error Handling example and the effect/wrap JSDoc with the mapError example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQ43QtcK3ZzzFbbxjAGFeg

Fixes the Effect integration docs and the JSDoc in
packages/effect/src/context.tsbefore@orpc/experimental-effectgoes stable.Changes
Tracerfrom@effect/opentelemetry, which doesn't exist in 4.x. It now usesOtelTracer.layerGlobal, which needs noResourcelayer. The tracer goes into the layer behindeffect/contextinstead ofEffect.provide(Layer)ineffect/wrap. The old way rebuilt the layer for everymiddlewareGenandhandlerGen(measured: 6 builds for 2 requests with 2 middlewares and a handler, against 1 build with aManagedRuntime).effect/wrap, for the same reason.return yield* Effect.fail(...), andClock.currentTimeMillisinstead ofDate.now()inEffect.sync..effectonimplement(contract);Effect.scopedforacquireRelease;MixedScheduler('sync'), runtime created at module scope;unstable_rethrowinsidecatchCause.effect/contextandeffect/wrapexamples now type-check.Not changed
effect/wrapexample still has an emptycatchCausebody. Theeffect/wraprework onclaude/festive-ride-65hat8fixes it. That branch also rewrites the OpenTelemetry section and theeffect/wrapJSDoc, so expect a conflict there.Verification
@effect/opentelemetry4.0.5 and next 16.4.2, using temporary*.test-d.tsfiles that I deleted afterwards.effect/context, Effect spans nesting under oRPC's spans, andunstable_rethrowlettingredirect()through.pnpm docs:validate,pnpm vitest run packages/effectandtscpass.Generated by Claude Code