Skip to content

fix(http): make HttpRouter entrypoints own their router - #8477

Merged
tim-smart merged 35 commits into
mainfrom
agent/bob/64843c2268fb
Sep 25, 2026
Merged

tim-smart merged 35 commits into
mainfrom
agent/bob/64843c2268fb

Conversation

@tim-smart

@tim-smart tim-smart commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

HttpRouter.serve, toWebHandler and toHttpEffect now own the router. Each call creates a new one, so two servers in one layer graph, or two handlers sharing a memoMap, no longer answer each other's routes.

  • HttpRouter.layer is removed. Holding a module-level router layer let apps share routes through memoization. Most callers just delete the Layer.provideMerge(HttpRouter.layer) line, since every entrypoint already supplies a router.
  • HttpRouter.make remains public for custom integrations. App layers may output another router, but entrypoints still serve their own router, not the app's output.
  • toHttpEffect takes a memoMap option.
  • The migration annotations and migration/v3-to-v4.md no longer point HttpLayerRouter.layer or HttpRouter.Default at the removed layer.
  • Tests cover isolation across all three entrypoints, shared route layers and the Layer.fresh workaround, app router outputs, and the public type surface. The HTTP/WebSocket RPC and MCP fixtures now register routes inside the app passed to the entrypoint.

Compatibility impact: removing HttpRouter.layer is a compile break, and routes registered on a router provided outside serve used to be served through the shared router but now get 404s. A route layer shared by two entrypoints in one graph (or through a shared memoMap) is memoized, so it registers on only one of them and 404s on the other. The changeset and entrypoint docs say to wrap it in Layer.fresh. This is an effect patch, following the rc convention.

Closes EFF-1570
Closes #8460

@changeset-bot

changeset-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2b37f5f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

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

@effect-janitor effect-janitor Bot added bug Something isn't working 4.0 labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 38.40 KB 38.40 KB 0.00 KB (0.00%)
basic.ts 6.88 KB 6.88 KB 0.00 KB (0.00%)
batching.ts 9.97 KB 9.97 KB 0.00 KB (0.00%)
brand.ts 6.57 KB 6.57 KB 0.00 KB (0.00%)
cache.ts 10.73 KB 10.73 KB 0.00 KB (0.00%)
config.ts 21.81 KB 21.81 KB 0.00 KB (0.00%)
differ.ts 20.96 KB 20.96 KB 0.00 KB (0.00%)
http-client.ts 22.11 KB 22.11 KB 0.00 KB (0.00%)
http-router.ts 33.45 KB 33.45 KB 0.00 KB (0.00%)
logger.ts 10.85 KB 10.85 KB 0.00 KB (0.00%)
metric.ts 8.83 KB 8.83 KB 0.00 KB (0.00%)
optic.ts 6.80 KB 6.80 KB 0.00 KB (0.00%)
pubsub.ts 15.00 KB 15.00 KB 0.00 KB (0.00%)
queue.ts 11.87 KB 11.87 KB 0.00 KB (0.00%)
schedule.ts 11.03 KB 11.03 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.42 KB 13.42 KB 0.00 KB (0.00%)
schema-binary.ts 39.56 KB 39.56 KB 0.00 KB (0.00%)
schema-class.ts 20.66 KB 20.66 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 31.53 KB 31.53 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 26.88 KB 26.88 KB 0.00 KB (0.00%)
schema-string-transformation.ts 14.14 KB 14.14 KB 0.00 KB (0.00%)
schema-string.ts 11.70 KB 11.70 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.70 KB 15.70 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 37.92 KB 37.92 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.11 KB 25.11 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 19.89 KB 19.89 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.06 KB 20.06 KB 0.00 KB (0.00%)
schema-toFormatter.ts 20.16 KB 20.16 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 24.43 KB 24.43 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 20.16 KB 20.16 KB 0.00 KB (0.00%)
schema.ts 19.87 KB 19.87 KB 0.00 KB (0.00%)
stm.ts 12.90 KB 12.90 KB 0.00 KB (0.00%)
stream.ts 9.82 KB 9.82 KB 0.00 KB (0.00%)

@tim-smart tim-smart changed the title fix(http): isolate routers for independent servers fix(http): make HttpRouter entrypoints own their router Sep 24, 2026
Comment thread packages/effect/src/http/HttpRouter.ts Outdated
@tim-smart
tim-smart merged commit ccd3440 into main Sep 25, 2026
13 checks passed
@tim-smart
tim-smart deleted the agent/bob/64843c2268fb branch September 25, 2026 02:38
kriegcloud added a commit to beep-effect/beep-effect that referenced this pull request Sep 28, 2026
… 1) (#1310)

* chore(deps): bump the Effect catalog to snapshot e5f7d12af9 (rc.118 + 1)

Move every Effect catalog entry from the pkg.pr.new snapshot of main
330b7475e2 to the snapshot of e5f7d12af9 (one commit after the
4.0.0-rc.118 tag). The Bun patches for effect and platform-node-shared
are re-keyed to the new URLs (upstream sources unchanged), the OSV
override is re-keyed, and the effect-vitest primitives graph, charter
fixtures, and inventory are re-pinned to the @effect/vitest@4.0.0-rc.118
tag (101 entries: the README gained a fixtures section).

HttpRouter.serve now owns the router it serves (Effect-TS/effect#8477),
so the professional-desktop sidecar builds its rpc server inside the
served app instead of as a sibling of it; the previous shape registered
the handlers on an unserved second protocol. The integration harness
follows the same shape. The knowledge command-surface parser drops the
pre-rc.118 effect/unstable/cli specifier.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(ontology-client): skip request cancellation on a disposed atom registry

The snapshot's AtomRegistry.reset empties the node map before running node
finalizers (Effect-TS/effect#8543), so the graph-worker finalizer's
registry.get on the watchdog/boundary/failure request atoms created nodes on
a disposed registry and threw "registry is disposed" in three Session atom
tests. Cancellation now bumps a request counter only while its atom still
has a node; a request nobody can answer needs no cancellation.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* test(epistemic-server): count SHACL violations without spying on the schema

The snapshot caches every schema's `make` as a lazily built, non-configurable
own property (Effect-TS/effect internal/schema/make.ts), so
`vi.spyOn(ShaclValidationViolation, "make")` throws "Attempting to change
value of a readonly property" once any test has built a violation. The
bounded-generation test now counts constructions through a module mock of
the layer's import, whose wrapper inherits the schema and shadows only
`make`. `vi` comes from `vitest` because only that import gets its `mock`
and `hoisted` calls hoisted; the effect-vitest inventory records the three
plain-vitest rows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpRouter.serve: two servers in one layer graph share the same router

1 participant