Skip to content

fix(devframe): dedup wire-service install across contexts sharing an RPC host - #338

Merged
antfu merged 1 commit into
mainfrom
fix/df0021-service-double-register
Sep 3, 2026
Merged

fix(devframe): dedup wire-service install across contexts sharing an RPC host#338
antfu merged 1 commit into
mainfrom
fix/df0021-service-double-register

Conversation

@antfubot

@antfubot antfubot commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Closes #335.

Problem

Declaring a wire service once on a definition (e.g. services: [{ package: '@devframes/service-open' }]) could emit a DF0021 RPC function "…" is already registered warning at startup. When the definition is mounted such that its services are installed by two devframe contexts that share a single RPC host (the shape the reporter traced in a kit-mounted setup), the service factory setup runs twice, so the second context re-registers the service's RPC and trips DF0021. The service still worked (first registration won), but the warning was noisy and misleading.

Cause

The services-host install-dedup guard (installed) was per host instance. Two contexts have two services hosts, so neither sees the other's install — and when they share one RPC host, the second install collides on the RPC registration.

Fix

Key the install-dedup registry by the shared RPC host object (a WeakMap<rpcHost, Map<pkg, api>>) instead of per-instance. The first install of a package now wins across every context on that RPC host. A sibling-context hit reuses the cached API and exposes it locally without re-running the factory (so no re-registration, no DF0021); a genuine same-host re-install still warns DF0066 as before. A context-less host (in-process provide/get only) falls back to a per-instance map.

Added a regression test covering two contexts that share one RPC host installing the same service: the factory runs once, the RPC is registered once and stays callable, both contexts expose the API, and no DF0021 is emitted.

This PR was created with the help of an agent.

…RPC host

A single wire service declared on a definition could register its RPC twice
and trip DF0021 when the definition is mounted into two contexts backed by one
RPC host (e.g. a kit mounting it alongside another context, so both iterate
def.services). The install-dedup guard was per services-host instance, so the
second context re-ran the service factory and re-registered its RPC.

Key the dedup registry by the shared RPC host so the first install wins across
sibling contexts; a sibling hit reuses the cached API without re-running setup,
while a genuine same-host re-install still warns DF0066.
@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 3, 2026

Copy link
Copy Markdown

◈ PR Lens

🟢 +0 new · 🟠 ~1 changed · 🔴 -0 removed · 1 flow · 2 files · commit 574ecbb


Architecture

Architecture diagram for devframes/devframe at 574ecbb

1 component touched across 3 lanes.

Open full size


Data flow

Data flow diagram for devframes/devframe at 574ecbb

Installing a wire service across sibling contexts

Open full size


Drill down
Devframe Core Engine — 1 component
🟡 CHANGED Wire Services Host

Manages wire service registration and deduplicates package installation per RPC host via WeakMap registry.


View

  • Architecture lens
  • Data flow lens
  • Expand every detail
  • Show unchanged neighbours

Tip

Would you rather run it from CI on a key of your own? Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and a model key in your repository secrets, say GEMINI_API_KEY. The Action asks Gemini by default, or OpenAI and any endpoint speaking /chat/completions through its provider input.

🪧 More tips
  • Run PR Lens on your own machine: npx skills add coldteadotai/pr-lens installs the agent skill. Then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Draw a diff before it is even a pull request: npx @coldtea/pr-lens-cli analyze --base origin/main reads the diff with your own model key, and npx @coldtea/pr-lens-cli render .pr-lens/graph.json draws the same lenses on your machine.
  • The boxes under View are live. Tick Architecture lens or Data flow lens to choose which diagrams appear, or Expand every detail to open every drill-down at once. The comment redraws in place a few seconds later.
  • Show unchanged neighbours lists the components this change did not touch alongside the ones it did, so the drill-down shows what the changed code sits next to.
  • GitHub will not let you zoom an image in a comment. The link under each diagram opens it full size on a page of its own, where you can.
  • The CLI's render picks up .github/pr-lens.yml automatically and applies your corrections (renames, exclusions, lane pins) at draw time.
  • PR Lens is free for open source. A star on the repository is what keeps it going.
  • Push a new commit and the whole comment re-renders for the new head. An older run never overwrites a newer one, so a slow render cannot put a stale diagram back.
  • The diagrams follow your GitHub theme, so dark mode gets the dark render and light mode the light one, and the moving dots show this pull request's data in motion.

◈ Rendered by PR Lens · crafted with ❤️ by the Coldtea team · Something drawn wrong?

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
devframe Skipped Skipped Sep 3, 2026 4:13am UTC

@antfu
antfu merged commit e597646 into main Sep 3, 2026
14 checks passed
@antfu
antfu deleted the fix/df0021-service-double-register branch September 3, 2026 04:25
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.

DF0021 false positive: a single service declaration registers open-in-editor twice (two contexts share one RPC host)

2 participants