fix(rpc): harden static RPC client against placeholder args and enveloped dumps#30
Merged
Merged
Conversation
…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
✅ Deploy Preview for devfra ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
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):TypeError: undefined is not iterableinreviveIfStructuredClone— structured-clone deserialization ran unconditionally. When a downstream consumer persists the fullStaticRpcDumpFileenvelope ({ serialization, fnName, data }) rather than justdata, the client tried to iterate the wrapper object and crashed.No dump match for "…" with args: [null]— framework-level setup hooks invoke argument-less static endpoints with a single placeholder ([null]/[undefined]). The strictargs.length > 0check rejected them, breaking client initialization.Fix
At the static RPC client boundary (
packages/devframe/src/client/static-rpc.ts):null/undefined) as a no-arg call for bothstaticand legacy inline manifest entries.{ serialization, fnName, data }envelope before decoding, so the client stays resilient whether a consumer persistsfile.data(as the bundledcreateBuildadapter does) or the wholeStaticRpcDumpFile(collectStaticRpcDumpand the type are public exports).structured-clone-esalways 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
serializationanddata, which legitimate dump files ({ output },{ inputs, output }, or SC arrays) never carry, so there are no false positives.Verification
static-rpc.test.tscovering placeholder args (static + legacy) and enveloped static/query dumps.pnpm typecheck,pnpm lint,pnpm test(364 tests), andpnpm buildall pass.This PR was created with the help of an agent.