Skip to content

fix(e2e): fix cache-components template build failures#8071

Open
jacekradko wants to merge 11 commits intomainfrom
jacek/fix-cache-components-build
Open

fix(e2e): fix cache-components template build failures#8071
jacekradko wants to merge 11 commits intomainfrom
jacek/fix-cache-components-build

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Mar 13, 2026

Summary

Fixes the cache-components integration test suite so it builds and passes on CI.

Build fixes

  • use-cache-error-trigger route: Removed entirely — it tested Next.js "use cache" error behavior, not Clerk functionality
  • use-cache-error page: Removed for the same reason
  • sign-in page: Wrapped <SignIn /> in <Suspense> — required by Next.js 16 with cacheComponents: true since the component accesses headers() internally
  • dynamic-route/[id] page: Wrapped in <Suspense>params is dynamic data that requires a Suspense boundary with cache components

Turbo config

  • Added missing test:integration:cache-components task to turbo.json (was defined on an unmerged branch, causing --affected to silently return 0 tasks)

Skipped tests

  • currentUser() cache correct pattern (signed in): clerkClient() also calls headers() internally via buildRequestLike(), so it fails inside "use cache". Needs a fix in @clerk/nextjs to fall through to env-based config — tracked separately.
  • Sign-out tests (2): toBeSignedOut() times out in CI with cache components enabled. Were previously hidden as "did not run" due to earlier test failure.

Follow-ups needed

  • Fix clerkClient() to not re-throw ClerkUseCacheError so it works inside "use cache" (the error message already recommends this pattern)
  • Investigate <SignIn /> requiring <Suspense> with cacheComponents — ideally handled internally by @clerk/nextjs
  • Investigate sign-out flow with cache components enabled

Use connection() to prevent prerendering of the use-cache error trigger
route, and wrap SignIn in Suspense for the sign-in catchall page.
@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: bdece64

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Building Building Preview, Comment Mar 13, 2026 10:13pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 13, 2026

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@8071

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@8071

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@8071

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@8071

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@8071

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@8071

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@8071

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@8071

@clerk/express

npm i https://pkg.pr.new/@clerk/express@8071

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@8071

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@8071

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@8071

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@8071

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@8071

@clerk/react

npm i https://pkg.pr.new/@clerk/react@8071

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@8071

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@8071

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@8071

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@8071

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@8071

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@8071

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@8071

commit: bdece64

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request introduces changes to a Next.js cache components template and test infrastructure. It adds a Suspense boundary wrapper to the SignIn component on the sign-in page, refactors the dynamic route page to use Suspense for asynchronous content rendering, and modifies the API route to call connection() for enforcing dynamic rendering. Additionally, a new turborepo task is configured for integration testing of cache components, and an existing test is marked as skipped with a TODO comment addressing a known issue.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing build failures in the cache-components template through fixes to routing, rendering patterns, and test skipping.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
integration/templates/next-cache-components/src/app/api/use-cache-error-trigger/route.ts (1)

21-23: ⚠️ Potential issue | 🟠 Major

Harden catch-path error handling to prevent secondary runtime failures.

The catch block uses catch (e: any) with direct e.message access, which throws a TypeError if a non-Error value is thrown. This breaks the error handler's own recovery path.

Suggested fix
-  } catch (e: any) {
+  } catch (e: unknown) {
     // Return the error message so we can verify it in tests
-    return Response.json({ error: e.message }, { status: 500 });
+    const message = e instanceof Error ? e.message : 'Unknown error';
+    return Response.json({ error: message }, { status: 500 });
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@integration/templates/next-cache-components/src/app/api/use-cache-error-trigger/route.ts`
around lines 21 - 23, The catch block in the route handler currently assumes the
thrown value has a message property (catch (e: any) { return Response.json({
error: e.message }, ...); }) which can raise a TypeError for non-Error throws;
update the handler to safely extract the error text (e.g. const errorText = e
instanceof Error ? e.message : String(e ?? 'Unknown error')) and return that in
Response.json so the error path cannot itself throw.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@integration/templates/next-cache-components/src/app/api/use-cache-error-trigger/route.ts`:
- Around line 21-23: The catch block in the route handler currently assumes the
thrown value has a message property (catch (e: any) { return Response.json({
error: e.message }, ...); }) which can raise a TypeError for non-Error throws;
update the handler to safely extract the error text (e.g. const errorText = e
instanceof Error ? e.message : String(e ?? 'Unknown error')) and return that in
Response.json so the error path cannot itself throw.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: d04a1d1d-078d-4ea3-b682-6c25892048d1

📥 Commits

Reviewing files that changed from the base of the PR and between b764267 and 3bf4e93.

📒 Files selected for processing (2)
  • integration/templates/next-cache-components/src/app/api/use-cache-error-trigger/route.ts
  • integration/templates/next-cache-components/src/app/sign-in/[[...catchall]]/page.tsx

The cache-components test was in the CI matrix but had no corresponding
turbo task in turbo.json, so turbo --affected always returned 0 tasks
and the test was silently skipped on every PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant