-
Notifications
You must be signed in to change notification settings - Fork 422
fix(nextjs,shared): Listen for hotloaded clerk-js script failing to download #5640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(nextjs,shared): Listen for hotloaded clerk-js script failing to download #5640
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: a30fa4b The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
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 |
| try { | ||
| await window.__clerk_script_promise; | ||
| } catch {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers
That whole block was required, because the browser would console an error for uncaught promise. We are catching the promise inside loadClerkJsScript from @clerk/shared but this code is usually bundled with the main chunk of the nextjs host application which takes significantly longer to load.
| const Script = props.router === 'app' ? 'script' : NextScript; | ||
|
|
||
| return ( | ||
| <Script |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if nonce needs to be passed here as well, and not just to the script we generate below ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a strict-dynamic CSP with a script-src 'nonce-****' value specified, yes, all inline scripts would need to have the nonce attribute, or they will be blocked
|
!snapshot |
|
Hey @panteliselef - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/agent-toolkit@0.0.23-snapshot.v20250416104815 --save-exact
npm i @clerk/astro@2.6.5-snapshot.v20250416104815 --save-exact
npm i @clerk/backend@1.29.0-snapshot.v20250416104815 --save-exact
npm i @clerk/chrome-extension@2.2.30-snapshot.v20250416104815 --save-exact
npm i @clerk/clerk-js@5.61.1-snapshot.v20250416104815 --save-exact
npm i @clerk/elements@0.23.15-snapshot.v20250416104815 --save-exact
npm i @clerk/clerk-expo@2.9.13-snapshot.v20250416104815 --save-exact
npm i @clerk/expo-passkeys@0.2.7-snapshot.v20250416104815 --save-exact
npm i @clerk/express@1.4.6-snapshot.v20250416104815 --save-exact
npm i @clerk/fastify@2.2.6-snapshot.v20250416104815 --save-exact
npm i @clerk/localizations@3.13.11-snapshot.v20250416104815 --save-exact
npm i @clerk/nextjs@6.15.1-snapshot.v20250416104815 --save-exact
npm i @clerk/nuxt@1.5.6-snapshot.v20250416104815 --save-exact
npm i @clerk/clerk-react@5.28.1-snapshot.v20250416104815 --save-exact
npm i @clerk/react-router@1.2.6-snapshot.v20250416104815 --save-exact
npm i @clerk/remix@4.5.18-snapshot.v20250416104815 --save-exact
npm i @clerk/shared@3.7.1-snapshot.v20250416104815 --save-exact
npm i @clerk/tanstack-react-start@0.13.6-snapshot.v20250416104815 --save-exact
npm i @clerk/testing@1.4.40-snapshot.v20250416104815 --save-exact
npm i @clerk/themes@2.2.33-snapshot.v20250416104815 --save-exact
npm i @clerk/types@4.54.1-snapshot.v20250416104815 --save-exact
npm i @clerk/vue@1.6.2-snapshot.v20250416104815 --save-exact |
| interface Window { | ||
| __clerk_script_promise?: Promise<unknown> | null | undefined; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this to @clerk/types instead?
|
We decided to not proceed with this approach |
Description
Replaces #5509 and unblocks #5476
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change