diff --git a/cli/commands/serve/proxy-extension-composition.test.ts b/cli/commands/serve/proxy-extension-composition.test.ts index ac61da617b..54dd713019 100644 --- a/cli/commands/serve/proxy-extension-composition.test.ts +++ b/cli/commands/serve/proxy-extension-composition.test.ts @@ -99,6 +99,7 @@ describe("standalone proxy extension composition", () => { "shutdown registration failed", ); assertEquals(tryResolve("TokenCacheStore"), undefined); + assertEquals(tryResolve(RedisRuntimeProviderName), undefined); loader = null; }); @@ -119,6 +120,7 @@ describe("standalone proxy extension composition", () => { "shutdown-hook disposal failed", ); assertEquals(tryResolve("TokenCacheStore"), undefined); + assertEquals(tryResolve(RedisRuntimeProviderName), undefined); loader = null; }); @@ -159,6 +161,7 @@ describe("standalone proxy extension composition", () => { } await cleanup; assertEquals(tryResolve("TokenCacheStore"), undefined); + assertEquals(tryResolve(RedisRuntimeProviderName), undefined); loader = null; }); }); diff --git a/cli/commands/serve/proxy-extension-composition.ts b/cli/commands/serve/proxy-extension-composition.ts index 20d0283057..eff11adb8d 100644 --- a/cli/commands/serve/proxy-extension-composition.ts +++ b/cli/commands/serve/proxy-extension-composition.ts @@ -46,9 +46,24 @@ const CACHE_EXTENSION_PACKAGE_NAME = "@veryfront/ext-cache-redis"; const REDIS_EXTENSION_SOURCE_DIRECTORY = "ext-redis"; const REDIS_EXTENSION_PACKAGE_NAME = "@veryfront/ext-redis"; +async function loadFirstPartyExtension( + sourceDirectory: string, + packageName: string, +): Promise { + const module = await importFirstPartyExtensionModule( + sourceDirectory, + packageName, + ); + if (typeof module.default !== "function") { + throw new NativeTypeError(`${packageName} must export an ExtensionFactory`); + } + return module.default; +} + /** - * Activate the standalone proxy's explicitly selected cache and Redis runtime - * providers. The returned loader owns provider teardown. + * Activate the standalone proxy's explicitly selected infrastructure extensions. + * The returned loader owns provider teardown; the proxy borrows the registered + * Redis runtime and optional `TokenCacheStore` providers. */ async function activateStandaloneProxyExtensionsInternal(): Promise { const cacheType = getEnv("CACHE_TYPE") || "memory"; @@ -58,41 +73,34 @@ async function activateStandaloneProxyExtensionsInternal(): Promise; origin: string; - packageName: string; - sourceDirectory: string; + source: "config"; }> = []; - if (cacheType === "extension" || cacheType === "redis") { - selected.push({ - origin: "standalone proxy cache selection", - packageName: CACHE_EXTENSION_PACKAGE_NAME, - sourceDirectory: CACHE_EXTENSION_SOURCE_DIRECTORY, - }); - } if (getEnv("REDIS_URL")) { - selected.push({ - origin: "standalone proxy routing invalidation", - packageName: REDIS_EXTENSION_PACKAGE_NAME, - sourceDirectory: REDIS_EXTENSION_SOURCE_DIRECTORY, + const redisExtension = await loadFirstPartyExtension( + REDIS_EXTENSION_SOURCE_DIRECTORY, + REDIS_EXTENSION_PACKAGE_NAME, + ); + extensions.push({ + extension: redisExtension(), + source: "config", + origin: "standalone proxy Redis runtime", }); } - if (selected.length === 0) return null; - - const extensions = await NativePromise.all(selected.map(async (definition) => { - const module = await importFirstPartyExtensionModule( - definition.sourceDirectory, - definition.packageName, + if (cacheType === "extension" || cacheType === "redis") { + const cacheExtension = await loadFirstPartyExtension( + CACHE_EXTENSION_SOURCE_DIRECTORY, + CACHE_EXTENSION_PACKAGE_NAME, ); - if (typeof module.default !== "function") { - throw new NativeTypeError(`${definition.packageName} must export an ExtensionFactory`); - } - return { - extension: module.default(), - source: "config" as const, - origin: definition.origin, - }; - })); + extensions.push({ + extension: cacheExtension(), + source: "config", + origin: "standalone proxy cache selection", + }); + } + if (extensions.length === 0) return null; const loader = new ExtensionLoader(cliLogger); try { @@ -110,7 +118,10 @@ async function activateStandaloneProxyExtensionsInternal(): Promise { "@opentelemetry/sdk-metrics": "2.8.0", "@opentelemetry/sdk-node": "0.218.0", "@sentry/deno": "10.68.0", - "brace-expansion": "5.0.8", + "brace-expansion": "5.0.9", "gaxios": "7.2.0", "gcp-metadata": "8.1.2", "protobufjs": "7.6.5", diff --git a/scripts/build/proxy-deno.lock b/scripts/build/proxy-deno.lock index e9d40ce6b6..9adb8b0cfa 100644 --- a/scripts/build/proxy-deno.lock +++ b/scripts/build/proxy-deno.lock @@ -1690,7 +1690,7 @@ "jsr:@std/testing@1.0.17", "npm:ai@7.0.41", "npm:bash-tool@1.3.18", - "npm:brace-expansion@5.0.8", + "npm:brace-expansion@5.0.9", "npm:just-bash@3.0.1" ] },