Skip to content

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

Description

@angusleeforbes

Package: @clerk/astro (observed on 2.17.13)
File: src/internal/create-clerk-instance.ts (createClerkInstanceInternal)

In createClerkInstanceInternal, the Clerk load call is wired as:

clerkJSInstance.load(initOptions).then(() => {
  $csrState.setKey("isLoaded", true);
  mountAllClerkAstroJSComponents();
  // ...addListener, etc.
}).catch(() => {});

The empty .catch() discards every error and every rejection from load(). Because mounting and the isLoaded state both live in the .then(), any failure or stall of that single load() call leaves the page in a fully silent broken state: the script is present, window.Clerk exists, window.Clerk.loaded stays false, no component mounts, and nothing is logged to the console.

Impact: consumers cannot diagnose sign-in/sign-up mount failures at all. We hit a Safari-only case where the initial load() did not complete in time for its .then() to run; the mount is wired to that one .then() with no retry, and the empty .catch() meant there was no console error, no telemetry, nothing. It cost most of a day to trace, entirely because the failure was swallowed.

Reproduction (Safari):

  • On initial load: typeof window.Clerk"object", window.Clerk.loadedfalse, and no environment/client network call is made after clerk.browser.js downloads.
  • Console is clean. No error, because the .catch() swallows it.
  • Manual await window.Clerk.load() later resolves fine, and a manual window.Clerk.mountSignIn(node) renders correctly. So the capability is present; only the integration's single, silent, no-retry call failed.

Requests:

  1. Do not swallow. At minimum console.error the caught error; ideally route it through Clerk's telemetry or an onError hook consumers can subscribe to.
  2. Consider decoupling the mount from a single load() resolution, or adding a bounded retry, so a slow/stalled first load() can still recover.

Environment: @clerk/astro 2.17.13, @clerk/clerk-js hotloaded at @5 (currently 5.127.1), Astro 5, Safari.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions