import { NextResponse } from "next/server"; import { settleRunningJobMetas } from "yt-dlp-transcript-common/jobs/bootQueuedJobs"; import { getRegistry } from "yt-dlp-transcript-common/jobs/registry"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { testRouteDenied } from "../_guard"; export const dynamic = "force-dynamic"; // E2E test harness only, GUARDED BY `E2E_TEST_ROUTES` like every other // /api/test route (see _guard.ts). It runs the boot pass over `running` metas // (common/jobs/bootQueuedJobs.ts `settleRunningJobMetas`) NOW, the way // editor/instrumentation.ts runs it once at boot: the e2e server boots once // for the whole suite, so a spec that plants a ghost meta (a dead process's // `running` job) has no other way to watch the pass close it. "This boot" is // this instant: every meta from before it, not in the registry, whose writer // is gone. export async function POST() { const denied = testRouteDenied(); if (denied) return denied; const result = await settleRunningJobMetas({ paths: getPaths(), bootedAt: Date.now(), isLive: (id) => getRegistry().get(id) !== undefined, }); return NextResponse.json(result); }