Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { getEnv, waitUntil } from "@vercel/functions";
import { kv } from "@vercel/kv";
import { mapValues } from "es-toolkit/object";
import { escapeRegExp } from "es-toolkit/string";
import { revalidatePath, revalidateTag } from "next/cache";
import { invalidateByTag, revalidatePath } from "next/cache";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function invalidateByTag does not exist in Next.js 15.5.4's cache API. The correct function is revalidateTag, which is still being used in similar route files across the codebase.

View Details
📝 Patch Details
diff --git a/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts b/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
index 298cd42fa..0e3d10ef0 100644
--- a/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
+++ b/packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts
@@ -29,7 +29,7 @@ import { getEnv, waitUntil } from "@vercel/functions";
 import { kv } from "@vercel/kv";
 import { mapValues } from "es-toolkit/object";
 import { escapeRegExp } from "es-toolkit/string";
-import { invalidateByTag, revalidatePath } from "next/cache";
+import { revalidateTag, revalidatePath } from "next/cache";
 import { type NextRequest, NextResponse } from "next/server";
 import { UnreachableCaseError } from "ts-essentials";
 import { getFaiClient } from "@/getFaiClient";
@@ -63,7 +63,7 @@ export async function GET(
     const start = performance.now();
 
     const { host, domain } = await props.params;
-    invalidateByTag(domain);
+    revalidateTag(domain);
 
     // delay to ensure invalidation propagates before cache is accessed
     await new Promise((resolve) => setTimeout(resolve, 500));

Analysis

Invalid function invalidateByTag imported from Next.js cache API

What fails: Route packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts imports invalidateByTag from next/cache, but this function doesn't exist in Next.js 15.5.4

How to reproduce:

cd packages/fern-docs/bundle
pnpm exec node -e "const { invalidateByTag } = require('next/cache'); console.log(typeof invalidateByTag);"
# Output: undefined

Result: TypeScript compilation error: '"next/cache"' has no exported member named 'invalidateByTag'. Did you mean 'revalidateTag'? Runtime error when endpoint is called: invalidateByTag is not a function

Expected: Should use revalidateTag function which is the correct Next.js cache invalidation API per Next.js documentation and matches usage in other route files in the codebase

import { type NextRequest, NextResponse } from "next/server";
import { UnreachableCaseError } from "ts-essentials";
import { getFaiClient } from "@/getFaiClient";
Expand Down Expand Up @@ -63,7 +63,7 @@ export async function GET(
const start = performance.now();

const { host, domain } = await props.params;
revalidateTag(domain);
invalidateByTag(domain);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calling non-existent invalidateByTag function will cause a TypeError.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The application attempts to import and call invalidateByTag from next/cache at line 66. This function does not exist in the Next.js API. When the /api/fern-docs/revalidate endpoint is invoked, the call to invalidateByTag(domain) will result in a TypeError: invalidateByTag is not a function, causing the process to terminate.

💡 Suggested Fix

Replace invalidateByTag(domain) with the correct Next.js cache invalidation API, revalidateTag(domain), to ensure proper cache invalidation.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/fern-docs/bundle/src/app/[host]/[domain]/api/fern-docs/revalidate/route.ts#L66

Potential issue: The application attempts to import and call `invalidateByTag` from
`next/cache` at line 66. This function does not exist in the Next.js API. When the
`/api/fern-docs/revalidate` endpoint is invoked, the call to `invalidateByTag(domain)`
will result in a `TypeError: invalidateByTag is not a function`, causing the process to
terminate.

Did we get this right? 👍 / 👎 to inform future reviews.


// delay to ensure invalidation propagates before cache is accessed
await new Promise((resolve) => setTimeout(resolve, 500));
Expand Down