-
Notifications
You must be signed in to change notification settings - Fork 353
fix(nextjs): Remove sourcemaps from bundled server-actions #3773
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
Conversation
🦋 Changeset detectedLatest commit: 5b833ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
8ec6e1b
to
910e99d
Compare
!snapshot |
Hey @nikosdouvlis - 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/astro@1.0.1-snapshot.v910e99d --save-exact
npm i @clerk/backend@1.4.0-snapshot.v910e99d --save-exact
npm i @clerk/chrome-extension@1.1.5-snapshot.v910e99d --save-exact
npm i @clerk/clerk-js@5.10.0-snapshot.v910e99d --save-exact
npm i @clerk/elements@0.10.5-snapshot.v910e99d --save-exact
npm i @clerk/clerk-expo@1.2.8-snapshot.v910e99d --save-exact
npm i @clerk/express@0.0.18-snapshot.v910e99d --save-exact
npm i @clerk/fastify@1.0.20-snapshot.v910e99d --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/localizations@2.5.0-snapshot.v910e99d --save-exact
npm i @clerk/nextjs@5.2.5-snapshot.v910e99d --save-exact
npm i @clerk/clerk-react@5.2.9-snapshot.v910e99d --save-exact
npm i @clerk/remix@4.2.4-snapshot.v910e99d --save-exact
npm i @clerk/clerk-sdk-node@5.0.17-snapshot.v910e99d --save-exact
npm i @clerk/shared@2.4.0-snapshot.v910e99d --save-exact
npm i @clerk/tanstack-start@0.1.8-snapshot.v910e99d --save-exact
npm i @clerk/testing@1.2.0-snapshot.v910e99d --save-exact
npm i @clerk/themes@2.1.13-snapshot.v910e99d --save-exact
npm i @clerk/types@4.9.0-snapshot.v910e99d --save-exact |
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.
Nice catch, was this happening for a while, or after a specific nextjs version ?
This PR excludes all server actions imported by client components. Even though we correctly build and bundle the Nextjs package (compiled files + sourcemaps), it seems that the sourcemaps for any server actions imported by client components are not served by nextjs when running npm run dev or npm run start. This PR solves the Error: Clerk: auth() was called but Clerk can't detect usage of authMiddleware(). error many users where getting during init. The error only popped up when browser devtools were open, as the browser would eventually request the sourcemap for the server action. The URL of the request is similar to /_next/...../filename.map.js which our default matcher ignores, so the middleware wouldn't run. The Clerk error would then be thrown if any Clerk helpers were used in a layout as the 404 page still renders that layout.
910e99d
to
5b833ab
Compare
I'm not sure when/if sourcemap handling changed at some point by Nextjs, but we introduced the |
Description
This PR excludes all server actions imported by client components. Even though we correctly build and bundle the Nextjs package (compiled files + sourcemaps), it seems that the sourcemaps for any server actions imported by client components are not served by nextjs when running
npm run dev
ornpm run start
.This PR solves the
Error: Clerk: auth() was called but Clerk can't detect usage of authMiddleware().
error many users where getting during init. The error only popped up when browser devtools were open, as the browser would eventually request the sourcemap for the server action.The URL of the request is similar to
/_next/...../filename.map.js
which our default matcher ignores, so the middleware wouldn't run. The Clerk error would then be thrown if any Clerk helpers were used in a layout as the 404 page still renders that layout.Checklist
npm test
runs as expected.npm run build
runs as expected.Type of change