Skip to content

Commit 28efa4d

Browse files
committed
fix(core): seed devframe:services state in static build
v0.9.1's Services feature (devframes/devframe#256) has the client read the devframe:services shared state on load. A static snapshot doesn't stand up the live hub, so nothing fired the services barrier that publishes that state — leaving the RPC dump without a match and the client logging a hard error. Fire context.services.ready() before collecting the dump (idempotent; publishes an empty state when no services are installed), mirroring the dock-renderers seeding.
1 parent f1a530d commit 28efa4d

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

e2e/tests/issue-339-static-build.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ describe('issue #339: static devtools build', () => {
4545
errors.find(e => /No dump match for "devtoolskit:internal:messages:list"/.test(e)),
4646
'RPC dump regression — messages:list dump missing for args [null]',
4747
).toBeUndefined()
48+
expect(
49+
errors.find(e => /No dump match for "devframe:rpc:server-state:get".+devframe:services/.test(e)),
50+
'RPC dump regression — devframe:services server-state missing (services barrier not fired at build)',
51+
).toBeUndefined()
4852
expect(errors, `unexpected errors:\n${errors.join('\n')}`).toHaveLength(0)
4953
expect(ready, 'DevTools SPA did not render').toBe(true)
5054
}

packages/core/src/node/build-static.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ export async function buildStaticDevTools(options: BuildStaticOptions): Promise<
8585
}
8686
;(await context.rpc.sharedState.get(DOCK_RENDERERS_STATE_KEY, { initialValue: {} })).mutate(() => rendererManifest)
8787

88+
// Fire the services collect-then-setup barrier `initHub` runs in dev. The
89+
// live hub isn't stood up for a static snapshot, so nothing else seeds the
90+
// `devframe:services` shared state the client reads on load — without this,
91+
// the RPC dump has no match for `server-state:get(["devframe:services"])`
92+
// and the client logs a hard error. `ready()` always publishes the state
93+
// (empty when no services are installed) and is idempotent.
94+
await context.services.ready()
95+
8896
await fs.mkdir(resolve(devToolsRoot, DEVTOOLS_RPC_DUMP_DIRNAME), { recursive: true })
8997
await fs.writeFile(resolve(devToolsRoot, DEVTOOLS_CONNECTION_META_FILENAME), JSON.stringify({ backend: 'static' }, null, 2), 'utf-8')
9098
await fs.writeFile(resolve(devToolsRoot, DEVTOOLS_DOCK_IMPORTS_FILENAME), renderDockImportsMap(context.docks.values()), 'utf-8')

0 commit comments

Comments
 (0)