Skip to content

Commit 47de930

Browse files
committed
fix(auth): resolve the cache service via getServiceAsync (async-registered)
The kernel registers `cache` as an ASYNC service, so the sync `ctx.getService('cache')` throws "Service 'cache' is async - use await" at AuthPlugin.init — breaking bootstrap (caught by the dogfood gate, which boots the real kernel; unit tests don't). Resolve via `getServiceAsync` wrapped in try/catch so an absent/not-ready cache falls to the per-process warning path instead of crashing boot. Verified: dogfood 36 files / 181 tests green; plugin-auth units green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014y5kiH3aPLWtRRRGcVrXcT
1 parent beecab4 commit 47de930

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/plugins/plugin-auth/src/auth-plugin.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,15 @@ export class AuthPlugin implements Plugin {
165165
// when no cache service is registered — with a warning, because a multi-node
166166
// deployment then silently rate-limits per-process (ADR-0069 D2 honesty).
167167
if (!authConfig.secondaryStorage) {
168-
const cache = ctx.getService<any>('cache');
168+
// The `cache` service is registered ASYNC — `getService` throws for it,
169+
// so resolve via `getServiceAsync` and treat any failure (not registered,
170+
// or not yet ready) as "no shared cache".
171+
let cache: any;
172+
try {
173+
cache = await (ctx as { getServiceAsync?: (n: string) => Promise<unknown> }).getServiceAsync?.('cache');
174+
} catch {
175+
cache = undefined;
176+
}
169177
if (cache && typeof cache.get === 'function' && typeof cache.set === 'function') {
170178
const { cacheSecondaryStorage } = await import('./secondary-storage.js');
171179
authConfig.secondaryStorage = cacheSecondaryStorage(cache);

0 commit comments

Comments
 (0)