Skip to content

feat(devframe): forward onFunctionError/onGeneralError to startHttpAndWs#84

Open
antfubot wants to merge 4 commits into
mainfrom
smart-times-shine
Open

feat(devframe): forward onFunctionError/onGeneralError to startHttpAndWs#84
antfubot wants to merge 4 commits into
mainfrom
smart-times-shine

Conversation

@antfubot

@antfubot antfubot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Why

A host that delegates its RPC/WS server to startHttpAndWs and owns its own structured error diagnostics (a coded error reporter, e.g. @vitejs/devtools's DTK0011/DTK0012) had no way to observe RPC failures. startHttpAndWs's internal createRpcServer call installs its own resolver on birpc's rpcOptions but had no passthrough for birpc's onFunctionError / onGeneralError — a thrown handler error or a message deserialize/serialize failure was silently absorbed instead of surfacing through the host's own diagnostics.

This is the one gap identified while evaluating a full createWsServerstartHttpAndWs delegation for a downstream consumer: without this, adopting startHttpAndWs wholesale would drop that host's structured error reporting.

What

Adds rpcOptions?: Pick<EventOptions<...>, 'onFunctionError' | 'onGeneralError'> to StartHttpAndWsOptions, forwarded verbatim into the internal createRpcServer's birpc options alongside the existing resolver. Matches birpc's own callback contract exactly (including the boolean | void return that lets a caller suppress birpc's default error response), so it's a true passthrough rather than a narrowed shim.

Testing

Added packages/devframe/src/node/__tests__/server.test.ts:

  • a thrown RPC handler error reaches rpcOptions.onFunctionError with the right name/error, and the caller still gets its rejection (nothing is swallowed)
  • a malformed inbound WS message reaches rpcOptions.onGeneralError

pnpm lint && pnpm test && pnpm typecheck && pnpm build all pass.


This PR was created with the help of an agent.

Hosts that delegate their RPC/WS server to startHttpAndWs and own their
own structured error diagnostics (e.g. a coded error reporter) had no
way to observe RPC failures — the internal createRpcServer call had no
passthrough for birpc's onFunctionError/onGeneralError, so those errors
were silently absorbed instead of surfacing through the host's own
diagnostics.
@netlify

netlify Bot commented Jul 9, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 145e583
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a4f9e208fee9e00073f7749
😎 Deploy Preview https://deploy-preview-84--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.

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