commit 4a5153e22bab19c8addf3dfc19867f21bb1b5c81
parent d2539fbed33b767c2e342e74d4c53969b6fd558a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 21 Oct 2026 18:23:06 -0400
safeRevalidate: a job revalidating in a request that is rendering is a skip, not a failed job; the cookie actions do not revalidate
Found by cookie-alerts.spec: Re-run stopped jobs started a fetch-windows job
inside the action, the action's revalidation re-rendered /, and the job's own
revalidation then threw 'used revalidatePath during render' after its work was
done — the job ended failed.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/editor/app/lib/safeRevalidate.test.ts b/editor/app/lib/safeRevalidate.test.ts
@@ -163,6 +163,18 @@ test("the real revalidatePath does throw here (the premise of the helper)", asyn
);
});
+test("a job revalidating inside a request that is rendering is a skip, not a failure", () => {
+ assert.equal(
+ runGuarded(() => {
+ throw new Error(
+ 'Route / used "revalidatePath /channels/test-youtube/videos/embed403a" during render which is unsupported. ' +
+ "To ensure revalidation is performed consistently it must always happen outside of renders and cached functions.",
+ );
+ }),
+ true,
+ );
+});
+
test("any other error is rethrown; a revalidation that runs is not a skip", () => {
assert.throws(
() =>
diff --git a/editor/app/lib/safeRevalidate.ts b/editor/app/lib/safeRevalidate.ts
@@ -23,9 +23,17 @@ import { revalidatePath, revalidateTag } from "next/cache";
export type RevalidateTarget = string | [string, "page" | "layout"];
const MISSING_STORE = /static generation store missing/;
+// THE OTHER WAY A JOB MEETS A STORE IT CANNOT USE (cookie refresh alerts,
+// 2026-10-21): a job that STARTED at once inside a server action carries that
+// request's store with it, and when the action also revalidated, Next renders
+// the page in the same request — a revalidation the job makes after that
+// finds the store in its render phase and throws `Route / used
+// "revalidatePath …" during render which is unsupported`. Same answer: the
+// page re-reads disk on its next request; skipped, never a failed job.
+const DURING_RENDER = /used "revalidate(?:Path|Tag)[^"]*" during render which is unsupported/;
function isMissingStore(err: unknown): boolean {
- return err instanceof Error && MISSING_STORE.test(err.message);
+ return err instanceof Error && (MISSING_STORE.test(err.message) || DURING_RENDER.test(err.message));
}
function describe(target: RevalidateTarget): string {
diff --git a/editor/app/operations/serviceCookiesActions.ts b/editor/app/operations/serviceCookiesActions.ts
@@ -11,7 +11,9 @@
// Re-run every job the alert stopped (failed or cancelled), retried
// from its replay descriptor ahead of the queue, as /jobs' Retry.
-import { revalidatePath } from "next/cache";
+// No revalidatePath here: the banner refetches its own view after each click
+// (CookieAlertsPanel's onChange), and the page is not re-rendered under a job
+// that started inside this request.
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { runManagedFunction } from "yt-dlp-transcript-common/jobs/streamCommand";
import { isServiceKey, serviceLabel } from "yt-dlp-transcript-common/lib/serviceCookies";
@@ -51,7 +53,6 @@ export async function recheckServiceCookiesAction(
if (!res.ok) return { ok: false, error: res.error };
void res.stream.cancel();
const done = await res.done;
- revalidatePath("/");
const o = outcome as RecheckOutcome | null;
if (done.status !== "done" || !o) {
return { ok: false, jobId: res.jobId, error: `The ${serviceLabel(service)} recheck ended ${done.status}.` };
@@ -65,7 +66,6 @@ export async function dismissServiceCookiesAction(
const bad = refuse(service);
if (bad) return { ok: false, error: bad };
const had = await dismissServiceCookieAlert(getPaths(), service);
- revalidatePath("/");
return {
ok: true,
message: had
@@ -100,7 +100,6 @@ export async function rerunServiceStoppedJobsAction(
}
}
await markServiceCookieRerun(paths, service, jobIds);
- revalidatePath("/");
return {
ok: true,
jobIds,
diff --git a/editor/e2e/cookie-alerts.spec.ts b/editor/e2e/cookie-alerts.spec.ts
@@ -106,7 +106,9 @@ test("two Rumble embeds refused raise the banner; Recheck with fresh cookies cle
};
const rerun = after.alerts.find((a) => a.service === "rumble")?.rerunJobIds ?? [];
expect(rerun).toHaveLength(1);
- expect(await waitJob(request, rerun[0])).toBe("done");
+ const rerunStatus = await waitJob(request, rerun[0]);
+ const tail = await request.get(`${baseUrl}/api/ops/job/${rerun[0]}?tail=40`, { headers: AUTH });
+ expect(rerunStatus, ((await tail.json()) as { tail?: string[] }).tail?.join("\n")).toBe("done");
});
test("ops: get services is behind the token; recheck-service refuses a name that is not a service", async ({ request }) => {
diff --git a/plans/FACTS.md b/plans/FACTS.md
@@ -11537,3 +11537,9 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri
`recheck-service`, `dismiss-service`, `rerun-service-jobs` (`{service}`). Doctor section "service cookies". The
e2e fake answers `embed403` URLs with the RumbleEmbed 403 until `fake-ytdlp.fresh-cookies` is in its cwd, and
`--skip-download --print id` is its recheck branch (`e2e/cookie-alerts.spec.ts`).
+- **`safeRevalidate` also skips `used "revalidatePath …" during render which is unsupported`** (found by this
+ lane's e2e): a job STARTED at once inside a server action carries that request's store; when the action (or
+ `retryJobAction`, which revalidates `/jobs`) triggers a re-render of the page in the same request, a revalidation
+ the job makes later finds the store in its render phase and threw — the job's work was done and it ended
+ `failed`. Counted as a skip like the missing store. The cookie actions do not revalidate at all (the banner
+ refetches its view).