fix(bootstrap): report a Service Worker that did not start through telemetry (06-05)

An ACTIVE worker whose install failed left a trace only in health(), which
nothing reads. The optional host now emits service-worker.start.failed on the
application telemetry port, and the recipe doc lists what else to wire.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-26 00:26:54 +09:00
co-authored by Claude Opus 5.5
parent 9f2305a562
commit cd47516592
6 changed files with 103 additions and 3 deletions
+11 -3
View File
@@ -1,5 +1,6 @@
import { resolveRuntimeCapabilities } from "../contracts/runtime-capabilities.ts";
import { INSTALLED_RUNTIME_CAPABILITIES } from "../features/installed-runtime-capabilities.ts";
import type { TelemetryPort } from "../application/ports/telemetry-port.ts";
import { createCompositionRoot } from "./composition-root.ts";
import { loadReleaseManifest } from "./load-release-manifest.ts";
import { loadRuntimeConfig } from "./load-runtime-config.ts";
@@ -23,17 +24,23 @@ export type RuntimeCompositionDependencies = Readonly<{
export async function createRuntimeComposition(
dependencies: RuntimeCompositionDependencies = {},
) {
// 06-05. The optional host reports a Service Worker that did not start
// through the same telemetry port as the application.
let telemetry: TelemetryPort | undefined;
const root = await createCompositionRoot({
loadConfig: () => loadRuntimeConfig({ fetcher: dependencies.fetcher }),
loadRelease: (runtime) =>
loadReleaseManifest(runtime, { fetcher: dependencies.fetcher }),
createAdapters: ({ config: runtime, release }) =>
createRuntimeAdapters({
createAdapters: async ({ config: runtime, release }) => {
const adapters = await createRuntimeAdapters({
runtime,
release,
fetcher: dependencies.fetcher,
host: dependencies.host,
}),
});
telemetry = adapters.outputPorts.telemetry;
return adapters;
},
});
const capabilities = resolveRuntimeCapabilities(
@@ -44,6 +51,7 @@ export async function createRuntimeComposition(
capabilities,
routerBasePath: root.config.build.routerBasePath,
buildId: root.release.buildId,
...(telemetry ? { telemetry } : {}),
...(dependencies.host
? {
host: dependencies.host as Parameters<