Skip to content

fix(rpc): harden static RPC client against placeholder args and enveloped dumps#30

Merged
antfu merged 1 commit into
devframes:mainfrom
antfubot:task/5zql5q
Jun 10, 2026
Merged

fix(rpc): harden static RPC client against placeholder args and enveloped dumps#30
antfu merged 1 commit into
devframes:mainfrom
antfubot:task/5zql5q

Conversation

@antfubot

Copy link
Copy Markdown
Contributor

Closes #26.

Problem

Loading the static build of a devframe app (e.g. Vite DevTools via vite preview) crashed with two runtime errors, both originating in the static RPC client (createStaticRpcCaller):

  1. TypeError: undefined is not iterable in reviveIfStructuredClone — structured-clone deserialization ran unconditionally. When a downstream consumer persists the full StaticRpcDumpFile envelope ({ serialization, fnName, data }) rather than just data, the client tried to iterate the wrapper object and crashed.
  2. No dump match for "…" with args: [null] — framework-level setup hooks invoke argument-less static endpoints with a single placeholder ([null]/[undefined]). The strict args.length > 0 check rejected them, breaking client initialization.

Fix

At the static RPC client boundary (packages/devframe/src/client/static-rpc.ts):

  • Treat placeholder-only args (null/undefined) as a no-arg call for both static and legacy inline manifest entries.
  • Unwrap the { serialization, fnName, data } envelope before decoding, so the client stays resilient whether a consumer persists file.data (as the bundled createBuild adapter does) or the whole StaticRpcDumpFile (collectStaticRpcDump and the type are public exports).
  • Guard structured-clone deserialization to array payloads, since structured-clone-es always encodes to a records array — a non-array means the payload was not SC-encoded and is passed through untouched.

Both failures were reproduced against the current code, then locked with regression tests. The envelope check keys on top-level serialization and data, which legitimate dump files ({ output }, { inputs, output }, or SC arrays) never carry, so there are no false positives.

Verification

  • Added 5 regression tests in static-rpc.test.ts covering placeholder args (static + legacy) and enveloped static/query dumps.
  • pnpm typecheck, pnpm lint, pnpm test (364 tests), and pnpm build all pass.

This PR was created with the help of an agent.

…oped dumps

Static preview crashed in two ways when consuming dumps produced by
downstream tools (e.g. @vitejs/devtools):

- Framework setup hooks call argument-less static endpoints with a
  single placeholder ([null]/[undefined]); the strict args.length check
  rejected them with "No dump match". Treat placeholder-only args as a
  no-arg call.
- structured-clone deserialization ran unconditionally, throwing
  "undefined is not iterable" when a consumer persisted the full
  StaticRpcDumpFile envelope ({ serialization, fnName, data }) rather
  than just data. Unwrap the envelope and guard deserialization to
  array payloads.

Closes devframes#26
@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 5e9506c
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a29027f66f7a40008fb1793
😎 Deploy Preview https://deploy-preview-30--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 f79453a into devframes:main Jun 10, 2026
12 checks passed
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.

[Bug] Vite DevTools static preview fails with TypeError: undefined is not iterable and No dump match

2 participants