Multiplayer agent harness for work.
Report published app crashes, failed starts and restarts to the admin error log (#2222)
Regan Bell22144734a0e1
diff --git a/docs/error-reporting.md b/docs/error-reporting.mdindex 4244bb3e3..55e989036 100644--- a/docs/error-reporting.md+++ b/docs/error-reporting.md@@ -21,3 +21,7 @@ The core reports one transaction per sampled HTTP request except `/healthz` (`htBrowser timing uses `SENTRY_BROWSER_TRACES_SAMPLE_RATE` on the web server together with `SENTRY_BROWSER_DSN`; see the web-ui README.Browser Sentry ignores plain network `TypeError` failures (`Failed to fetch`, `NetworkError when attempting to fetch resource.`, `Load failed`) and `AbortError` cancellations; HTTP 4xx/5xx failures still report.++## Published apps++On the AWS and Porter app hosts, published-app failures become operator error records in the app owner's scope, so they reach the admin errors view and Sentry: `deploy:app_start_failed` (publish failed, including an app that only answered 5xx on `/` for the readiness window), `deploy:app_restarted` (the supervisor restarted the app since the last visit-time check), and `deploy:app_down` (the app and its supervisor are gone). Each record names the deployment and carries up to 4 KB of the app's recent output, with the app's env values and known secret patterns masked. Fly relies on its machine TCP check, so its readiness does not reject 5xx and its failures surface only as the publish error; Docker uses its restart policy and does not report.diff --git a/src/deploy/aws-deploy-provider.ts b/src/deploy/aws-deploy-provider.tsindex 0b181ac71..3502fe1ba 100644--- a/src/deploy/aws-deploy-provider.ts+++ b/src/deploy/aws-deploy-provider.ts@@ -10,7 +10,14 @@ import { createNoopAdvisoryLock, type AdvisoryLock } from "../persistence/advisoimport { createKeyedQueue, sleep } from "../util/async.ts";import { shq } from "../util/shell.ts";import { swallow } from "../util/errors.ts";-import { appGone, listeningOn, supervised, waitAppReady } from "./shared-deploy-provider.ts";+import {+ appGone,+ appReporter,+ listeningOn,+ supervised,+ waitAppReady,+ type AppErrorSink,+} from "./shared-deploy-provider.ts";const AGENT_PORT_DEFAULT = 8080;const APP_PORT_DEFAULT = 8081;@@ -82,6 +89,7 @@ export interface AwsDeployProviderOptions {fetchImpl?: typeof fetch;s3?: Pick<S3Client, "send">;sts?: Pick<STSClient, "send">;+ onError?: AppErrorSink;}export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployProvider {@@ -424,7 +432,7 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPfor (const f of files) await writeAbs(id, endpoint, posixJoin(root, normalizeRelPath(f.path)), bytes(f.data));}- async function startApp(id: string, endpoint: string, version: DeploymentVersion): Promise<void> {+ async function startApp(d: Deployment, id: string, endpoint: string, version: DeploymentVersion): Promise<void> {const envExports = Object.entries(version.env ?? {}).filter(([k]) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(k)).map(([k, v]) => `export ${k}=${shq(v)}`)@@ -456,6 +464,7 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPwindowSec: APP_READY_WINDOW_SEC,pidPath: PID_PATH,logPath: LOG_PATH,+ report: appReporter(opts.onError, d, version.env),});}@@ -509,7 +518,7 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPif (cur) await store.put(d.id, { ...cur, dataCredsAtMs: Date.now() });});}- await startApp(id, endpoint, version);+ await startApp(d, id, endpoint, version);}async function endpointFor(d: Deployment, microvmId: string, endpoint: string): Promise<DeployEndpoint> {@@ -527,7 +536,11 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPreturn result;}- const resolveLive = async (d: Deployment, genCurrent: () => boolean): Promise<DeployEndpoint | null> => {+ const resolveLive = async (+ d: Deployment,+ version: DeploymentVersion,+ genCurrent: () => boolean,+ ): Promise<DeployEndpoint | null> => {const stored = await store.get(d.id);if (!stored) return null;try {@@ -547,7 +560,8 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPawait ensureRunning(stored.microvmId, stored.endpoint);const exec = (script: string, timeoutSec: number) =>execRaw(stored.microvmId, stored.endpoint, script, timeoutSec);- if (await appGone(exec, { appPort, pidPath: PID_PATH })) return null;+ const report = appReporter(opts.onError, d, version.env);+ if (await appGone(exec, { appPort, pidPath: PID_PATH, logPath: LOG_PATH, report })) return null;} catch (e) {if (!(e instanceof AwsApiError && (e.status >= 500 || e.status === 429))) throw e;}@@ -615,14 +629,14 @@ export function createAwsDeployProvider(opts: AwsDeployProviderOptions): DeployPreconcile: (d, version, input) => place(d, version, input),- async resolveEndpoint(d, _version): Promise<DeployEndpoint | null> {+ async resolveEndpoint(d, version): Promise<DeployEndpoint | null> {const cached = resolveCache.get(d.id);if (cached && Date.now() < cached.untilMs) return cached.endpoint;const inflight = inflightResolves.get(d.id);if (inflight) return inflight;const gen = resolveGens.get(d.id) ?? 0;const genCurrent = (): boolean => (resolveGens.get(d.id) ?? 0) === gen;- const resolve = resolveLive(d, genCurrent)+ const resolve = resolveLive(d, version, genCurrent).then((endpoint) => {if (endpoint && genCurrent()) {if (resolveCache.size > 500) {diff --git a/src/deploy/porter-deploy-provider.ts b/src/deploy/porter-deploy-provider.tsindex e86b26a88..85906a039 100644--- a/src/deploy/porter-deploy-provider.ts+++ b/src/deploy/porter-deploy-provider.ts@@ -3,7 +3,7 @@ import { LRUCache } from "lru-cache";import { NotFoundError } from "porter-sandbox";import type { Deployment, DeploymentVersion } from "./deploy-store.ts";import type { DeployEndpoint, DeployProvider } from "./deploy-provider.ts";-import { appGone, supervised, waitAppReady } from "./shared-deploy-provider.ts";+import { appGone, appReporter, supervised, waitAppReady, type AppErrorSink } from "./shared-deploy-provider.ts";import { normalizeRelPath, posixJoin, readTree } from "./deploy-fs.ts";import { makeTar } from "../sandbox/tar.ts";import {@@ -66,6 +66,7 @@ export interface PorterDeployProviderOptions {client?: PorterClientLike;store?: DurableMap<StoredPorterDeployBody>;advisoryLock?: AdvisoryLock;+ onError?: AppErrorSink;}export function createPorterDeployProvider(opts: PorterDeployProviderOptions): DeployProvider {@@ -145,7 +146,7 @@ export function createPorterDeployProvider(opts: PorterDeployProviderOptions): Dif (version.homeDir) await unpackTree(sandboxId, volumeId, HOME_DIR, version.homeDir);}- async function startApp(sandboxId: string, version: DeploymentVersion): Promise<void> {+ async function startApp(d: Deployment, sandboxId: string, version: DeploymentVersion): Promise<void> {const inner = `cd ${shq(APP_DIR)}; ${version.entrypoint}`;const launch = `sh -c ${shq(supervised(inner, appPort, PID_PATH))} < /dev/null > ${shq(LOG_PATH)} 2>&1 & echo $! > ${shq(PID_PATH)}`;const script = [@@ -160,6 +161,7 @@ export function createPorterDeployProvider(opts: PorterDeployProviderOptions): DwindowSec: readyWindowSec,pidPath: PID_PATH,logPath: LOG_PATH,+ report: appReporter(opts.onError, d, version.env),});}@@ -234,7 +236,7 @@ export function createPorterDeployProvider(opts: PorterDeployProviderOptions): Dawait waitPorterRunning(name, sb);const address = await addressOf(d, sb);await materialize(sb.id, volumeId, version);- await startApp(sb.id, version);+ await startApp(d, sb.id, version);await store.put(d.id, { deploymentId: d.id, sandboxId: sb.id, name, ...address, createdAtMs: Date.now() });return endpointOf(address);} catch (e) {@@ -243,7 +245,7 @@ export function createPorterDeployProvider(opts: PorterDeployProviderOptions): D}}),- async resolveEndpoint(d): Promise<DeployEndpoint | null> {+ async resolveEndpoint(d, version): Promise<DeployEndpoint | null> {const cached = resolveCache.get(d.id);if (cached) return cached;const stored = await liveStored(d);@@ -252,7 +254,8 @@ export function createPorterDeployProvider(opts: PorterDeployProviderOptions): Dreturn null;}const exec = (script: string, timeoutSec: number) => execRaw(stored.sandboxId, script, timeoutSec);- if (await appGone(exec, { appPort, pidPath: PID_PATH })) return null;+ const report = appReporter(opts.onError, d, version.env);+ if (await appGone(exec, { appPort, pidPath: PID_PATH, logPath: LOG_PATH, report })) return null;const endpoint = endpointOf(stored);if (resolveCacheMs > 0) resolveCache.set(d.id, endpoint);return endpoint;diff --git a/src/deploy/shared-deploy-provider.ts b/src/deploy/shared-deploy-provider.tsindex 50c6a0756..94dd5f8ec 100644--- a/src/deploy/shared-deploy-provider.ts+++ b/src/deploy/shared-deploy-provider.ts@@ -1,19 +1,42 @@import type { ExecResult } from "../sandbox/sandbox.ts";import { shq } from "../util/shell.ts";-import { swallow } from "../util/errors.ts";+import { errMessage, swallow } from "../util/errors.ts";+import { redactSecrets } from "../harness/redact-secrets.ts";+import { createSecretValueMasker } from "../security/secret-masking.ts";+import type { Deployment } from "./deploy-store.ts";+const EXIT_APP_SERVER_ERROR = 96;const EXIT_APP_EXITED = 98;const EXIT_APP_GONE = 99;+const REPORT_LOG_BYTES = 4000;+const REPORT_CONTEXT_LINES = 40;const READY_EXEC_GRACE_SEC = 30;const APP_PROBE_TIMEOUT_SEC = 5;+const EXITED_MARK = "qm: entrypoint exited";type Exec = (script: string, timeoutSec: number) => Promise<Pick<ExecResult, "stdout" | "stderr" | "code">>;+export type AppErrorSink = (+ e: { category: string; code: string; message: string; scopeLabel: string },+ error?: unknown,+) => void;+type Report = (code: string, detail: string) => Error;++export function appReporter(onError: AppErrorSink | undefined, d: Deployment, env?: Record<string, string>): Report {+ const mask = createSecretValueMasker(env);+ return (code, detail) => {+ const error = new Error(redactSecrets(mask(`app ${d.name ?? d.id} (deployment ${d.id}): ${detail}`)));+ onError?.({ category: "deploy", code, message: error.message, scopeLabel: d.ownerScopeId }, error);+ return error;+ };+}+export interface AppReadyOptions {appPort: number;windowSec: number;pidPath: string;logPath: string;+ report?: Report | undefined;}export const listeningOn = (port: number): string =>@@ -33,15 +56,45 @@ export function supervised(inner: string, appPort: number, pidPath: string): str].join("; ");}-export async function appGone(exec: Exec, opts: { appPort: number; pidPath: string }): Promise<boolean> {- const probe =- `${listeningOn(opts.appPort)}; listening && exit 0; pid=$(cat ${shq(opts.pidPath)} 2>/dev/null || true); ` +- `[ -n "$pid" ] && { kill -0 -"$pid" 2>/dev/null || kill -0 "$pid" 2>/dev/null; } && exit 0; exit ${EXIT_APP_GONE}`;+export async function appGone(+ exec: Exec,+ opts: { appPort: number; pidPath: string; logPath: string; report?: Report | undefined },+): Promise<boolean> {+ const log = shq(opts.logPath);+ const seen = shq(`${opts.logPath}.reported`);+ const probe = [+ listeningOn(opts.appPort),+ `pid=$(cat ${shq(opts.pidPath)} 2>/dev/null || true)`,+ `s=$(cat ${seen} 2>/dev/null || true)`,+ `if ! listening && ! { [ -n "$pid" ] && { kill -0 -"$pid" 2>/dev/null || kill -0 "$pid" 2>/dev/null; }; }; then ` ++ `[ -n "$pid" ] && [ "$s" != "down $pid" ] && { echo "down $pid" > ${seen}; echo down; tail -c ${REPORT_LOG_BYTES} ${log} 2>/dev/null; }; exit ${EXIT_APP_GONE}; fi`,+ `n=$(wc -l < ${exitedPath(opts.pidPath)} 2>/dev/null || echo 0); r=0`,+ `[ "\${s% *}" = "$pid" ] && r=\${s#* }`,+ `[ "$n" -gt "$r" ] || exit 0`,+ `echo "$pid $n" > ${seen}; echo $((n - r)); grep -F -B ${REPORT_CONTEXT_LINES} ${shq(EXITED_MARK)} ${log} | tail -c ${REPORT_LOG_BYTES}`,+ ].join("; ");const r = await exec(probe, APP_PROBE_TIMEOUT_SEC).catch((e) => {swallow("deploy: app liveness probe", e);return null;});- return r?.code === EXIT_APP_GONE;+ if (r?.code === EXIT_APP_GONE) {+ const [first, ...tail] = r.stdout.trim().split("\n");+ if (first === "down")+ opts.report?.(+ "app_down",+ `app stopped and nothing restarted it; last output:\n${tail.join("\n").trim() || "(none)"}`,+ );+ return true;+ }+ const out = r?.code === 0 ? r.stdout.trim() : "";+ if (out) {+ const [count, ...rest] = out.split("\n");+ opts.report?.(+ "app_restarted",+ `app exited ${count} time(s) and was restarted; output before exiting:\n${rest.join("\n")}`,+ );+ }+ return false;}export async function waitAppReady(exec: Exec, opts: AppReadyOptions): Promise<void> {@@ -49,17 +102,20 @@ export async function waitAppReady(exec: Exec, opts: AppReadyOptions): Promise<v`pid=$(cat ${shq(opts.pidPath)} 2>/dev/null || true); died=0; ` +`end=$(( $(date +%s) + ${opts.windowSec} )); ` +`while [ "$(date +%s)" -lt "$end" ]; do ` +- `curl -s --max-time 2 -o /dev/null http://127.0.0.1:${opts.appPort}/ && exit 0; ` ++ `code=$(curl -s --max-time 2 -o /dev/null -w '%{http_code}' http://127.0.0.1:${opts.appPort}/); ` ++ `[ "$code" != 000 ] && [ "$code" -lt 500 ] && exit 0; ` +`{ kill -0 -"$pid" 2>/dev/null || kill -0 "$pid" 2>/dev/null; } && [ ! -f ${exitedPath(opts.pidPath)} ] || died=1; ` +- `sleep 0.5; done; [ "$died" = 1 ] && exit ${EXIT_APP_EXITED}; exit 1`;+ `sleep 0.5; done; [ "$died" = 1 ] && exit ${EXIT_APP_EXITED}; ` ++ `[ "$code" -ge 500 ] 2>/dev/null && { echo "$code"; exit ${EXIT_APP_SERVER_ERROR}; }; exit 1`;const r = await exec(probe, opts.windowSec + READY_EXEC_GRACE_SEC);if (r.code === 0) return;- const log = await exec(`tail -c 2000 ${shq(opts.logPath)} 2>/dev/null || true`, 30)+ const log = await exec(`tail -c ${REPORT_LOG_BYTES} ${shq(opts.logPath)} 2>/dev/null || true`, 30).then((out) => `${out.stdout}${out.stderr}`.trim())- .catch(() => "");- const why =- r.code === EXIT_APP_EXITED- ? `the version's entrypoint exited without binding port ${opts.appPort}`- : `app never listened on port ${opts.appPort} within ${opts.windowSec}s`;- throw new Error(why + (log ? `; last output from the entrypoint:\n${log}` : "; the entrypoint produced no output"));+ .catch((e: unknown) => `(the app log could not be read: ${errMessage(e)})`);+ let why = `app never listened on port ${opts.appPort} within ${opts.windowSec}s`;+ if (r.code === EXIT_APP_EXITED) why = `the version's entrypoint exited without binding port ${opts.appPort}`;+ if (r.code === EXIT_APP_SERVER_ERROR)+ why = `app answered HTTP ${r.stdout.trim()} on / for the whole ${opts.windowSec}s readiness window`;+ const message = why + (log ? `; last output from the entrypoint:\n${log}` : "; the entrypoint produced no output");+ throw opts.report?.("app_start_failed", message) ?? new Error(message);}diff --git a/src/wiring.ts b/src/wiring.tsindex d3d1f3f6c..50ab31113 100644--- a/src/wiring.ts+++ b/src/wiring.ts@@ -841,13 +841,19 @@ export function buildApp(});const mcpServers = createMcpServerStore(artifactMap<McpServer>("mcp_servers"));const errors = withErrorReporting(config.databaseUrl ? createPostgresErrorLog(config.databaseUrl) : createErrorLog());- const sandboxOnError = (e: { category: string; code: string; message: string; scopeLabel?: string }) =>- errors.record({- category: e.category,- code: e.code,- message: e.message,- scopeLabel: (e.scopeLabel ?? "unknown") as ScopeId,- });+ const sandboxOnError = (+ e: { category: string; code: string; message: string; scopeLabel?: string },+ error?: unknown,+ ) =>+ errors.record(+ {+ category: e.category,+ code: e.code,+ message: e.message,+ scopeLabel: (e.scopeLabel ?? "unknown") as ScopeId,+ },+ error,+ );const buildLocal = (): Sandbox =>createLocalSandbox(workspace, {...config.localSandbox,@@ -1668,6 +1674,7 @@ export function buildApp(...(!config.awsDeploy.dataBucket && config.awsSandbox.s3Bucket ? { dataBucket: config.awsSandbox.s3Bucket } : {}),advisoryLock,store: artifactMap<StoredDeployBody>("aws_deploy_bodies"),+ onError: sandboxOnError,});if (config.deployProvider === "fly" && config.flyDeploy.sharedAppName && !config.flyDeploy.wireguardPeers)throw new Error("Fly shared apps require FLY_DEPLOY_WIREGUARD_PEERS for private connectivity");@@ -1696,6 +1703,7 @@ export function buildApp(...config.porterDeploy,advisoryLock,store: artifactMap<StoredPorterDeployBody>("porter_deploy_bodies"),+ onError: sandboxOnError,}),};if (diff --git a/test/aws-deploy-provider.test.ts b/test/aws-deploy-provider.test.tsindex 3dcdca902..ba83f1a2a 100644--- a/test/aws-deploy-provider.test.ts+++ b/test/aws-deploy-provider.test.ts@@ -460,7 +460,7 @@ test("resolveEndpoint: destroy invalidates a hot resolve cache", async () => {test("resolveEndpoint: an app whose process and supervisor are both gone returns null, and the re-apply reuses the body", async () => {const { api, counts } = fakeApi();- const appGoneProbe = (cmd: string): boolean => cmd.includes("listening && exit 0") && cmd.includes("qm-app.pid");+ const appGoneProbe = (cmd: string): boolean => cmd.includes("qm-app.pid") && cmd.includes("exit 99");const { fetchImpl, execs } = fakeDaemon({ execCode: (cmd) => (appGoneProbe(cmd) ? 99 : 0) });const p = provider(api, fetchImpl);const d = deployment(ID);diff --git a/test/porter-deploy-provider.test.ts b/test/porter-deploy-provider.test.tsindex 75970b538..0defc251e 100644--- a/test/porter-deploy-provider.test.ts+++ b/test/porter-deploy-provider.test.ts@@ -27,6 +27,8 @@ let fake: FakePorter;let store: DurableMap<StoredPorterDeployBody>;let provider: DeployProvider;let appPort: number;+let reported: { category: string; code: string; message: string; scopeLabel: string }[] = [];+let reportedErrors: unknown[] = [];const freePort = (): Promise<number> =>new Promise((resolve) => {@@ -67,7 +69,14 @@ const freeListener = (): void => {if (appPort) spawnSync("sh", ["-c", `lsof -ti tcp:${appPort} -sTCP:LISTEN | xargs kill 2>/dev/null; true`]);};-function make(extra: { terminateLag?: number; resolveCacheMs?: number; visibility?: "public" | "private" } = {}): void {+function make(+ extra: {+ terminateLag?: number;+ resolveCacheMs?: number;+ visibility?: "public" | "private";+ readyWindowSec?: number;+ } = {},+): void {fake?.cleanup();fake = installFakePorter(extra.terminateLag ? { terminateLag: extra.terminateLag } : {});store = createMemoryMap<StoredPorterDeployBody>();@@ -75,15 +84,21 @@ function make(extra: { terminateLag?: number; resolveCacheMs?: number; visibilitappsDomain: "apps.test",namePrefix: "qmt",appPort,- readyWindowSec: 10,+ readyWindowSec: extra.readyWindowSec ?? 10,resolveCacheMs: extra.resolveCacheMs ?? 0,...(extra.visibility ? { visibility: extra.visibility } : {}),client: fake.client,store,+ onError: (e, error) => {+ reported.push(e);+ reportedErrors.push(error);+ },});}beforeEach(async () => {+ reported = [];+ reportedErrors = [];freeListener();appPort = await freePort();make();@@ -265,6 +280,62 @@ test("resolveEndpoint returns null when the app and its supervisor are both goneassert.equal(await provider.resolveEndpoint!({ ...d, endpoint: applied }, v), null);});+test("an app that only answers 5xx fails publish, and the failure reaches the error log with its redacted output", async () => {+ make({ readyWindowSec: 3 });+ const d = deployment("dep-5f", "broken");+ const server =+ "console.log('connecting to ' + process.env.DATABASE_URL); console.log('booting with api_key=sk-livevalue1234567890'); require('http').createServer((q, s) => { s.statusCode = 500; s.end('boom'); }).listen(process.env.PORT);";+ const env = { DATABASE_URL: "postgres://app:hunter2hunter2@db/app" };+ await assert.rejects(+ provider.apply(d, version({ "server.js": server }, "node server.js", { env })),+ (e: Error) => e === reportedErrors[0] && /HTTP 500[\s\S]*booting/.test(e.message),+ );+ assert.equal(reported.length, 1);+ const [e] = reported;+ assert.equal(e!.code, "app_start_failed");+ assert.equal(e!.scopeLabel, d.ownerScopeId);+ assert.match(e!.message, /app broken \(deployment dep-5f\): app answered HTTP 500[\s\S]*booting/);+ assert.doesNotMatch(e!.message, /sk-livevalue|hunter2/);+ assert.match(e!.message, /connecting to <redacted:DATABASE_URL>/);+});++test("a crash the supervisor recovers from is reported once, with the output before the exit", async () => {+ const d = deployment("dep-5g", "crashy2");+ const crashy = SERVER.replace(+ "if (q.url === '/data')",+ "if (q.url === '/crash') { console.error('fatal: out of widgets'); process.exit(3); } if (q.url === '/data')",+ );+ const v = version({ "server.js": crashy }, "node server.js");+ const applied = await provider.apply(d, v);+ await fetch(`http://127.0.0.1:${appPort}/crash`).catch(() => {});+ for (const end = Date.now() + 5_000; Date.now() < end; await new Promise((r) => setTimeout(r, 100)))+ if (/entrypoint exited/.test((await provider.logs!(d, { tailLines: 50 })) ?? "")) break;+ assert.deepEqual(await provider.resolveEndpoint!({ ...d, endpoint: applied }, v), applied);+ assert.equal(reported.length, 1);+ assert.equal(reported[0]!.code, "app_restarted");+ assert.match(reported[0]!.message, /exited 1 time\(s\)[\s\S]*out of widgets[\s\S]*exited with status 3/);+ await provider.resolveEndpoint!({ ...d, endpoint: applied }, v);+ assert.equal(reported.length, 1, "the same crash is not reported twice");+});++test("an app found down with no supervisor is reported with its last output", async () => {+ const d = deployment("dep-5h", "gone2");+ const v = version({ "server.js": SERVER }, "node server.js");+ const applied = await provider.apply(d, v);+ const { sandboxId } = (await store.get("dep-5h"))!;+ await fake.client.sandboxes.raw.exec(sandboxId, { command: ["sh", "-c", 'kill -KILL -"$(cat /tmp/qm-app.pid)"'] });+ for (const end = Date.now() + 5_000; Date.now() < end; await new Promise((r) => setTimeout(r, 100)))+ if (!(await fetchText("/").catch(() => ""))) break;+ assert.equal(await provider.resolveEndpoint!({ ...d, endpoint: applied }, v), null);+ assert.equal(await provider.resolveEndpoint!({ ...d, endpoint: applied }, v), null);+ assert.deepEqual(+ reported.map((e) => e.code),+ ["app_down"],+ "the visit path probes twice; one outage is one report",+ );+ assert.match(reported[0]!.message, /server starting/);+});+test("resolveEndpoint caches the live answer instead of asking Porter on every request", async () => {make({ resolveCacheMs: 60_000 });const d = deployment("dep-5b", "cached");