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
+10
View File
@@ -8,6 +8,7 @@ import type {
RuntimeStopReason,
} from "../contracts/runtime-capabilities.ts";
import type { ServiceWorkerRuntimeHost } from "../contracts/service-worker.ts";
import type { TelemetryPort } from "../application/ports/telemetry-port.ts";
import { createServiceWorkerRuntimeHost } from "./register-service-worker.ts";
/**
@@ -39,6 +40,8 @@ export type OptionalRuntimeHostInput = Readonly<{
host?: Parameters<typeof createServiceWorkerRuntimeHost>[0]["host"];
blockers?: readonly (() => boolean)[];
observe?: (observation: Readonly<{ event: string; outcome: string }>) => void;
/** 06-05. Receives `service-worker.start.failed`. */
telemetry?: TelemetryPort;
}>;
export function createOptionalRuntimeHost(
@@ -107,6 +110,13 @@ export function createOptionalRuntimeHost(
: outcome.kind === "INCOMPATIBLE"
? "INCOMPATIBLE"
: "DEGRADED";
if (outcome.kind === "FAILED" || outcome.kind === "INCOMPATIBLE") {
input.telemetry?.emit("service-worker.start.failed", {
error_kind:
outcome.kind === "FAILED" ? outcome.code : outcome.kind,
build_id: input.buildId,
});
}
}
}
if (!stopRequested) started = true;