Fix RpcServer toHttpEffect lifetime#2162
Draft
wking-io wants to merge 1 commit into
Draft
Conversation
|
tim-smart
reviewed
May 11, 2026
| Ping: () => Effect.succeed("pong") | ||
| })), | ||
| Effect.provideService(RpcSerialization.RpcSerialization, RpcSerialization.jsonRpc()), | ||
| Effect.scoped |
Collaborator
There was a problem hiding this comment.
This Effect.scoped will shutdown the server immediately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toHttpEffectserver loop from the ambient scope so the returned HTTP effect can be used after construction scope cleanup.ExitandClientEnd, allowingQueue.collectto finish.toHttpEffectis constructed in a short-lived scope before handling a request.Context
A downstream Cloudflare Worker setup using Alchemy constructs
RpcServer.toHttpEffect(...)forRpcSerialization.jsonRpc(). After fixing the separate finalizerrequestIdsTDZ crash, the official adapter decoded the request and sent EOF, then hung in the non-framedQueue.collectpath until workerd canceled the request. Runtime logs showed the server loop never emittedExit/ClientEndbefore the ambient request scope finalized.This change makes
toHttpEffectown the server loop lifetime independently of the construction scope and avoids treating non-framed one-shot HTTP requests as disconnects before their collected response is produced.Test plan
pnpm vitest run packages/effect/test/rpc/RpcServer.test.tspnpm --filter effect check