Skip to content

fix(devframe): carry meta base for cross-base RPC inheritance; surface missing mountConnectionMeta#98

Merged
antfu merged 2 commits into
mainfrom
many-pears-smoke
Jul 16, 2026
Merged

fix(devframe): carry meta base for cross-base RPC inheritance; surface missing mountConnectionMeta#98
antfu merged 2 commits into
mainfrom
many-pears-smoke

Conversation

@antfubot

@antfubot antfubot commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Background

vitejs/devtools#414 is a downstream workaround in @vitejs/devtools-kit for two root causes its author flags as living upstream in devframe. This PR fixes both here, so the kit (and any other hub) no longer has to work around them.

Root cause 1 — same-origin meta inheritance dropped its base

A mounted devframe SPA inherits the connection meta from a same-origin parent window before it fetches its own __connection.json. The meta was published with a relative websocket.path but without the base it was resolved against, so a child mounted at a different base (a hub mounting Terminals, the Inspector, …) resolved that path against its own mount and dialed the wrong endpoint. The kit worked around this with an entire getDevToolsRpcClient wrapper that republishes an absolute path.

Now the client annotates the meta it publishes on the shared window with an optional baseUrl field — the absolute, browser-derived (proxy-safe) URL of the __connection.json it was loaded from — and an inheriting client resolves the WS path against that base rather than its own. The value on the window stays a plain ConnectionMeta (no wrapper object), and baseUrl is client-annotated, not part of the served JSON.

Root cause 2 — missing mountConnectionMeta failed silently

mountDevframe invoked ctx.host.mountConnectionMeta?.(base), so a host that forgot to implement the hook became a silent no-op: the SPA's ./__connection.json fetch fell through to the HTML fallback and its panel stayed empty / stuck loading. Mounting a devframe with a servable distDir on such a host now emits a new DF8106 diagnostic. Static-snapshot hosts that bake the file can implement a no-op to acknowledge it.

Also

  • Added ConnectionMeta.baseUrl (optional, client-annotated) and documented it.
  • Updated DevframeHost.mountConnectionMeta doc, docs/guide/hub.md, and added docs/errors/DF8106.md.
  • Tests for the publish/inherit paths and the DF8106 fired/not-fired paths.

Verification

pnpm lint, pnpm typecheck, pnpm build, and pnpm test (664 passed) all pass.

This PR was created with the help of an agent.

…e missing mountConnectionMeta

A mounted devframe SPA inherits the connection meta from a same-origin
parent window before it fetches its own `__connection.json`. The meta was
published with a relative `websocket.path` but without the base it was
resolved against, so a child mounted at a different base resolved the path
against its own mount and dialed the wrong endpoint. Publish the meta
paired with the absolute (proxy-safe) base it was resolved from, and have
the client inherit that base. Backward-compatible: a bare ConnectionMeta on
the shared key is still accepted. Exposes `readPublishedConnectionMeta` +
`PublishedConnectionMeta` so hosts can reuse the shape.

Also make a missing host `mountConnectionMeta` non-silent: mounting a
devframe with a servable distDir on a host lacking the hook previously fell
through to the HTML fallback and broke the SPA silently. Emit a new DF8106
diagnostic instead.
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit 09ab911
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a578925ebb22d0008182592
😎 Deploy Preview https://deploy-preview-98--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.

Replace the published `{ meta, metaBaseUrl }` wrapper with an optional
`baseUrl` field annotated directly onto the ConnectionMeta the client
publishes on the shared window. The value on the window stays a plain
ConnectionMeta, dropping the wrapper type and the dual-form detection
helper. `baseUrl` is client-annotated (not served), documented as such.
@antfu
antfu merged commit acc95a3 into main Jul 16, 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.

2 participants