clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
955 stars 210 forks source link

`@clerk/nextjs@5.2.0` cause a build warning in NextJS middleware #3660

Closed arvinxx closed 1 day ago

arvinxx commented 2 days ago

Preliminary Checks

Reproduction

https://github.com/lobehub/lobe-chat/tree/reproduction/clerk-nextjs-5.2.0

Publishable key

no need, it's a build time issue

Description

here is the build log:

   Creating an optimized production build ...
 ✓ (pwa) Compiling for server...
 ✓ (pwa) Compiling for server...
 ✓ (pwa) Compiling for client (static)...
 ○ (pwa) Service worker: /vercel/path1/public/sw.js
 ○ (pwa)   URL: /sw.js
 ○ (pwa)   Scope: /
 ⚠ Compiled with warnings
./node_modules/@clerk/nextjs/dist/esm/server/clerkMiddleware.js
A Node.js module is loaded ('async_hooks' at line 3) which is not supported in the Edge Runtime.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
Import trace for requested module:
./node_modules/@clerk/nextjs/dist/esm/server/clerkMiddleware.js
./node_modules/@clerk/nextjs/dist/esm/server/index.js
./node_modules/@clerk/shared/dist/chunk-RSOCGYTF.mjs
A Node.js API is used (MessageEvent at line: 28) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime
Import trace for requested module:
./node_modules/@clerk/shared/dist/chunk-RSOCGYTF.mjs
./node_modules/@clerk/shared/dist/index.mjs
./node_modules/@clerk/nextjs/dist/esm/server/utils.js
./node_modules/@clerk/nextjs/dist/esm/server/clerkClient.js
./node_modules/@clerk/nextjs/dist/esm/server/index.js

you can see the error from @clerk/nextjs. please remove this usage:

https://github.com/clerk/javascript/blob/1a704ed9de3ad222ff17d10cb383639b2fc038b9/packages/nextjs/src/server/clerkMiddleware.ts#L10

Environment

Next.JS: 14.2.4
@nextjs/clerk: >=5.2.0
LauraBeatris commented 2 days ago

Hi @arvinxx, thanks for raising the issue! We're working on a fix for it and it should be released soon.

LauraBeatris commented 1 day ago

@arvinxx The fix has been merged and will soon release a patch for @clerk/nextjs! 🫡