Skip to content

fix(node): export the structural RpcFunctionsHost type from devframe/node#112

Merged
antfu merged 1 commit into
mainfrom
curvy-melons-remain
Jul 17, 2026
Merged

fix(node): export the structural RpcFunctionsHost type from devframe/node#112
antfu merged 1 commit into
mainfrom
curvy-melons-remain

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Why

Vite DevTools' 0.7.4 upgrade (vitejs/devtools#435) broke on context.rpc as RpcFunctionsHost. DevframeNodeContext.rpc is typed as the structural RpcFunctionsHost (exported from the devframe main entry), but devframe/node exported the implementation class RpcFunctionsHost, which additionally declares the @internal members _rpcGroup, _asyncStorage, and _emitSessionDisconnected.

The two RpcFunctionsHost exports had diverged, leaking the implementation's internal members into a public type. Any consumer importing RpcFunctionsHost from devframe/node and casting context.rpc to it hit:

Conversion of type G to type RpcFunctionsHost may be a mistake … RpcFunctionsHost is missing _rpcGroup, _asyncStorage, _emitSessionDisconnected.

This worked in 0.7.3.

What

  • Renamed the implementation class RpcFunctionsHostRpcFunctionsHostImpl (kept internal — no longer re-exported from devframe/node).
  • Re-export the structural RpcFunctionsHost type from devframe/node (the same type the devframe main entry and DevframeNodeContext.rpc already use), so import { RpcFunctionsHost } from 'devframe/node' resolves to a type structurally compatible with context.rpc.
  • createHostContext still returns context.rpc typed as that structural RpcFunctionsHost.
  • Updated internal importers (context.ts, server.ts, auth/revoke.ts, tests) to the impl class where impl-only members are touched.
  • Added a type-level test asserting DevframeNodeContext['rpc'] equals the exported RpcFunctionsHost, plus @ts-expect-error guards that the @internal members stay off the public type (enforced by tsc --noEmit).
  • Regenerated the devframe/node API snapshot.
  • Documented that RPC name-map augmentations should target the canonical devframe / devframe/types module specifiers (matching @devframes/hub), since augmenting a renamed re-export alias no longer merges after the interfaces moved into a bundled chunk in 0.7.4.

Acceptance

  • ctx.rpc as RpcFunctionsHost (imported from either devframe or devframe/node) type-checks.
  • No @internal members appear on the public RpcFunctionsHost type.
  • API snapshot updated; a type-level test asserts DevframeNodeContext['rpc'] is assignable to the exported RpcFunctionsHost.

Verified with pnpm lint, pnpm typecheck, pnpm build, and vitest (739 tests pass).

This PR was created with the help of an agent.

The devframe/node entry exported the implementation class RpcFunctionsHost,
whose @internal members (_rpcGroup, _asyncStorage, _emitSessionDisconnected)
leaked into the public type. This diverged from DevframeNodeContext.rpc and the
devframe main entry, which use the structural RpcFunctionsHost type, so casting
ctx.rpc as RpcFunctionsHost (imported from devframe/node) failed with TS2352 on
devframe >=0.7.4.

Rename the implementation to RpcFunctionsHostImpl (kept internal) and re-export
the structural RpcFunctionsHost type from devframe/node so it matches ctx.rpc.
@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit c621338
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a59ee262643a10008be7442
😎 Deploy Preview https://deploy-preview-112--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@antfu
antfu merged commit 89c4df2 into main Jul 17, 2026
11 of 12 checks passed
@antfu
antfu deleted the curvy-melons-remain branch July 17, 2026 09:01
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.

2 participants