Repository navigation
Replies: 4 comments
|
Confirmed 1:1 on master (c291e79), including the regression bisect:
Fix direction: mirror the soft-injection pattern this same plugin already uses for its |
|
Confirmed with a fresh native Web profile using One additional failure mode: a nested registration can leave the outer Loader entry ACTIVE while the child fiber is FAILED, so HTTP readiness or top-level plugin status hides the broken channel. export const inject = ['sessions', 'sessionPersistence'];
export function apply(ctx) {
ctx.inject(['connection', 'webServer'], scoped => {
scoped.connection.rpc.handle('/example', async () => ({ok: true, value: 'hello'}));
});
}Observed after native app readiness: outer fiber state 2, child state 3, all four services present, and awaiting the child throws I also exercised an alternative through the existing authenticated Fetch registry, without modifying the runtime: scoped.connection.fetch.register({
path: '/api/example/echo',
methods: ['POST'],
requestBody: 'buffered',
fetch: async () => Response.json({ok: true, value: 'hello'}),
});With the native Web transport, the same route returns 200 with its authenticated browser cookie, 401 without a cookie, and 403 with a foreign Origin. This offers a workaround without duplicating the RPC envelope or exposing an unauthenticated raw route. It does require using Fetch from the Client instead of The reproductions use separate native provider and consumer plugin scopes: a test that provides WebServer directly on the root can mask the dependency-context failure. I have not tested a newer published runtime for this report. |
Still present on
|
Still present on 0.2.2-rc.1, and cordis 4.1 also breaks the
|
| host | c.connection |
c.root.connection |
c.extend({ webServer }) |
c.connection + one-line fix |
|---|---|---|---|---|
| 0.2.1-rc.5 (cordis 4.0.5) | 405 | 401 | 401 | β |
| 0.2.2-rc.1 (cordis 4.1.0) | 405 | 405 | 401 | 401 |
- The error is
cannot get property "webServer" without inject, captured with a try/catch in the plugin. - Without the try/catch, nothing is logged. The throw happens inside an effect in the
ctx.injectcallback and is swallowed. The only symptom is 405s in the browser (also noted in [Bug] client-connection is missing the webServer injection: every third-party rpc.handle registration fails silentlyΒ #6880).
Fix (verified)
In register(), change owner.webServer.register(route) to owner.get('webServer').register(route). With only that change in the installed dsh-client-connection lib, the c.connection variant mounts on 0.2.2-rc.1 (401). The other reads in rpc-host.ts already use this.owner.get('webServer'). Separately, it would help a lot if a throw from an inject callback or effect were logged.
Workaround that works on 0.2.0-rc.2, 0.2.1-rc.5 and 0.2.2-rc.1
Credit for the derived-context idea goes to @shuaigekda in anweat/dsh-browser#49. It uses only public API:
c.extend({ webServer: c.get('webServer') }).connection.rpc.handle(channel, handler)The rpc getter captures the derived context as owner, and owner.webServer then resolves as an own property instead of going through the inject check. It depends on that getter detail, so the host-side fix is still the right one.
Uh oh!
There was an error while loading. Please reload this page.
Summary
In
dsh-client-connection0.1.5-rc.x (verified on 0.1.5-rc.2),connection.rpc.handle(channel, handler)throwscannot get property "webServer" without injectfor every caller, so any third-party plugin that registers a dedicated RPC channel fails to boot. Declaringinject: ['webServer']in the calling plugin does not help.This worked in 0.1.2-rc.1 and broke in 0.1.5-rc.x.
Root cause
0.1.5-rc.x narrowed the connection plugin's own inject from
["webServer", "credentials"]to["credentials"], mounting only its own/apiroute inside a softctx.inject(["webServer"], ...)child fiber:But
HostConnectionService.register()β the path behindrpc.handle()used by third-party channels β still does:Cordis resolves service property access in the service's own fiber scope (the shadow/receiver mechanism):
ownerhere is the ctx captured byget rpc()(this.ctx), andowner.webServeris resolved against the client-connection fiber β which no longer injectswebServer. The fiber walk climbs to the root fiber and throwscannot get property "webServer" without inject.Because the lookup happens in the connection plugin's scope, nothing on the caller side (including
inject: ['connection', 'webServer']) can satisfy it. Empirically:['connection']['connection', 'webServer']ctx.inject(['connection','webServer'], c => c.connection.rpc.handle(...))Reproduction
Minimal cordis-level repro (cordis 4.0.2 + dsh-client-connection 0.1.5-rc.2):
Real-world impact: community plugins registering settings-page RPC channels (
dsh-pocket,dsh-notify-plugin,dsh-advisors) all crash the web profile boot:Suggested fix
register()should not resolvewebServerthroughowner. Mount channel routes through the connection plugin's own soft-injected webServer scope, e.g. queue channel registrations and flush them inside the existingctx.inject(["webServer"], webCtx => ...)block (which also fixes ordering for registrations that happen before/after webServer appears), keepingowner.effect(...)only for disposal bookkeeping:(Or collect pending routes on the service and have the existing
webCtxblock register/unregister them.)Workaround used by affected plugins meanwhile
Register the prefix route directly on
webServerfrom the plugin's own fiber βctx.inject(['connection', 'webServer'], c => c.effect(() => c.webServer.register(route)))β keepingconnection.requestRejection(req)as the auth fence and replicating the client-request/server-response envelope bridge. This boots on both 0.1.2 and 0.1.5, but every plugin has to duplicate the envelope logic, so a core fix is still needed.All reactions