Skip to content

✨ feat(server): add IPC JSON-RPC transport - #2080

Merged
roninjin10 merged 2 commits into
mainfrom
fix/ipc-server
Jul 30, 2026
Merged

✨ feat(server): add IPC JSON-RPC transport#2080
roninjin10 merged 2 commits into
mainfrom
fix/ipc-server

Conversation

@roninjin10

@roninjin10 roninjin10 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Bug

@tevm/server only exposed an HTTP JSON-RPC server, so Node clients using viem's ipc() transport had no Unix domain socket endpoint to connect to. A test importing createIpcServer was written first and reproduced the missing public API.

This closes the viem migration blocker described as:

"WebSocket and IPC transports ... still need it [anvil]."

Root cause

The server package had no node:net server, stream framing, or persistent connection layer. Although Tevm's JSON-RPC actions can create subscriptions, there was also no transport adapter to forward node events as eth_subscription notifications or clean them up when a connection closes.

Fix

  • Add public createIpcServer API backed by a Unix domain socket.
  • Parse fragmented, concatenated, and newline-delimited JSON-RPC frames safely across UTF-8 chunks.
  • Route regular, batch, and notification requests through the existing Tevm JSON-RPC dispatcher.
  • Stream newHeads, newPendingTransactions, and filtered logs subscription notifications.
  • Clean up subscription filters and event listeners on eth_unsubscribe or socket close.
  • Add configurable message and batch limits, public barrel exports, documentation, and a changeset.

Tests

  • pnpm vitest run packages/server/src/createIpcServer.spec.ts — 9 passed.
  • pnpm --dir packages/server typecheck — passed.
  • pnpm --dir packages/server lint:check — passed.
  • pnpm --dir packages/server build:dist and pnpm --dir packages/server build:types — passed.

The IPC integration tests use real Unix sockets, a real Tevm memory client, and viem's real ipc() transport. They cover request/response framing, invalid requests, batches, notifications, size limits, all supported subscription types, filtering, unsubscribe behavior, and connection cleanup without mocks.

The full neighboring server run completed with 67 passing and 2 failing tests. Both failures are newly landed parseRequest.spec.ts exact-message assertions already present on origin/main; this branch has no diff in either parseRequest.js or parseRequest.spec.ts. On the original requested clone base, the neighboring server suite passed all 65 tests and the coverage run passed every configured threshold (87.52% statements, 81.02% branches, 91.25% functions, 89.3% lines).

Add a Unix domain socket JSON-RPC server to packages/server with newline-delimited framing and subscription support so viem's ipc() transport can use Tevm instead of Anvil.

🤖 Generated with Smithers multi-agent orchestration

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25bb2c5

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

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

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "@evmts/*" is specified in the `ignore` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
node Ready Ready Preview Jul 30, 2026 1:15am
tevm-monorepo-app Ready Ready Preview Jul 30, 2026 1:15am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
tevm-monorepo-tevm Ignored Ignored Jul 30, 2026 1:15am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@roninjin10, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2427a78f-7ce5-4ac8-8514-2d4a7172bd93

📥 Commits

Reviewing files that changed from the base of the PR and between 846b040 and 25bb2c5.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .changeset/fresh-sockets-listen.md
  • .changeset/ipc-server.md
  • packages/server/README.md
  • packages/server/package.json
  • packages/server/src/createIpcServer.js
  • packages/server/src/createIpcServer.spec.ts
  • packages/server/src/index.js
  • packages/server/src/index.spec.ts
  • packages/server/src/index.ts
  • packages/server/src/internal/createIpcConnectionHandler.js
  • packages/server/src/internal/createIpcSubscription.js
  • packages/server/src/internal/extractJsonRpcFrames.js

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.

@claude

claude Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude

claude Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

<prompt>Add a Unix domain socket JSON-RPC server to packages/server with newline-delimited framing, viem ipc() compatibility, and subscription notifications.</prompt>
@claude

claude Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


I'll analyze this and get back to you.

@roninjin10
roninjin10 marked this pull request as ready for review July 30, 2026 01:36
@roninjin10
roninjin10 merged commit c8d1952 into main Jul 30, 2026
11 of 14 checks passed
@roninjin10
roninjin10 deleted the fix/ipc-server branch July 30, 2026 01:36
@roninjin10

Copy link
Copy Markdown
Collaborator Author

Blocking transport findings:

  1. packages/server/src/internal/createIpcSubscription.js:49-115 pushes events but never drains the node filter that eth_subscribe created. Those filters continue buffering every block/log/transaction for polling even though IPC has already pushed each event. I reproduced this with a newHeads subscription: after three delivered blocks, filter.blocks.length was 3. It therefore grows without bound for a long-lived IPC connection. The WebSocket PR explicitly adds drainFilter for this reason, so the two transports are already inconsistent. Move subscription binding/draining into a shared helper and clear the relevant filter buffers as notifications are delivered.

  2. createIpcConnectionHandler.js:43-65 dispatches eth_unsubscribe to the global node before checking ownership in the connection-local subscriptions map. A different IPC connection can therefore unsubscribe a subscription it does not own; its local listener is not removed, while the owning connection can keep receiving events for a filter the node considers deleted. Check subscriptions.has(id) before dispatch and return false for foreign IDs, matching the connection-scoped behavior implemented in ✨ feat(server): add WebSocket JSON-RPC transport with eth_subscribe support #2084.

  3. Notification subscriptions leak completely. dispatch calls handleBulkRequest(..., { suppressNotifications: true }); an eth_subscribe request with no id still creates the node filter, but its response is suppressed, so lines 45-53 never record the ID and socket cleanup can never unsubscribe it. Either reject eth_subscribe notifications before dispatch or capture and immediately dispose the created subscription.

  4. A syncing subscription returns an ID, but createIpcSubscription falls through the default branch and never emits a notification. The current test only proves that the filter is deleted on close, not that the advertised subscription works. ✨ feat(server): add WebSocket JSON-RPC transport with eth_subscribe support #2084 implements initial and transition notifications, which is another reason this logic should be shared and tested once across both transports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant