Skip to content

fix(astro): Log Clerk.load() failures in Astro - #9361

Open
wobsoriano wants to merge 3 commits into
mainfrom
rob/fix-issue-9360
Open

fix(astro): Log Clerk.load() failures in Astro#9361
wobsoriano wants to merge 3 commits into
mainfrom
rob/fix-issue-9360

Conversation

@wobsoriano

Copy link
Copy Markdown
Member

Description

When clerk.load() failed, the error was thrown away by an empty .catch(). Nothing mounted and nothing showed up in the console, so there was no way to tell what went wrong. Now the error gets logged, same as the Vue and React SDKs do.

Fixes #9360

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview Aug 7, 2026 10:11pm
swingset Ready Ready Preview Aug 7, 2026 10:11pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 30f88a1

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

This PR includes changesets to release 1 package
Name Type
@clerk/astro Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9361

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9361

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9361

@clerk/expo

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

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@9361

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 30f88a1

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-08-07T22:14:42.828Z

Summary

Metric Count
Packages analyzed 19
Packages with changes 0
🔴 Breaking changes 0
🟡 Non-breaking changes 0
🟢 Additions 0

No API Changes Detected

All packages have stable APIs with no detected changes.


Report generated by Break Check

Last ran on 30f88a1.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Astro Clerk initialization catch handler now logs rejected Clerk.load() errors. The log uses the error stack, message, or error object. Regression coverage verifies that rejected loads do not mark CSR state as loaded or mount Astro components. A patch changeset documents the behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main Astro change: logging Clerk.load() failures.
Description check ✅ Passed The description explains the swallowed load error, the logging fix, SDK alignment, and linked issue.
Linked Issues check ✅ Passed The changes log Clerk.load() rejections and test that failed loads leave state unchanged without mounting, satisfying issue #9360.
Out of Scope Changes check ✅ Passed The changeset, implementation update, and regression test are directly related to the linked issue and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/astro/src/internal/__tests__/create-clerk-instance.test.ts (1)

124-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a typed Clerk mock for the test setup.

Define a Pick<BrowserClerk, 'load' | 'addListener'> mock and install it on window through a typed helper. Remove the repeated window as any casts from this test file.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/astro/src/internal/__tests__/create-clerk-instance.test.ts` around
lines 124 - 128, Update the test setup around the Clerk mock to define a typed
Pick<BrowserClerk, 'load' | 'addListener'> object, then install it on window
through a typed helper. Replace the repeated window as any casts throughout
create-clerk-instance tests while preserving the existing load rejection and
listener behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/astro/src/internal/create-clerk-instance.ts`:
- Around line 93-95: Update the rejection handler for clerkJSInstance.load() to
accept unknown values and safely narrow them before accessing stack or message,
while still logging null, undefined, and other non-Error rejection values
without throwing. Add coverage for these non-Error rejection cases.

---

Nitpick comments:
In `@packages/astro/src/internal/__tests__/create-clerk-instance.test.ts`:
- Around line 124-128: Update the test setup around the Clerk mock to define a
typed Pick<BrowserClerk, 'load' | 'addListener'> object, then install it on
window through a typed helper. Replace the repeated window as any casts
throughout create-clerk-instance tests while preserving the existing load
rejection and listener behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 8df57982-dce5-4ee2-8a64-e1d8d6737d67

📥 Commits

Reviewing files that changed from the base of the PR and between 34d278b and 0c14090.

📒 Files selected for processing (3)
  • .changeset/astro-log-load-errors.md
  • packages/astro/src/internal/__tests__/create-clerk-instance.test.ts
  • packages/astro/src/internal/create-clerk-instance.ts
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • clerk/clerk_go (manual)
  • clerk/dashboard (manual)
  • clerk/accounts (manual)
  • clerk/backoffice (manual)
  • clerk/clerk (manual)
  • clerk/clerk-docs (manual)
  • clerk/cloudflare-workers (manual)
  • clerk/clerk-ios (auto-detected)
  • clerk/cli (auto-detected)
  • clerk/clerk-android (auto-detected)

Comment thread packages/astro/src/internal/create-clerk-instance.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[astro] Empty .catch() in createClerkInstanceInternal silently swallows all load() failures

1 participant