Skip to content
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

Issues regarding integration of Clerk with NextJS #26086

Open
StilauGamer opened this issue Oct 9, 2024 · 8 comments · Fixed by #27455
Open

Issues regarding integration of Clerk with NextJS #26086

StilauGamer opened this issue Oct 9, 2024 · 8 comments · Fixed by #27455
Labels
bug Something isn't working correctly nextjs Issue relating to Next.js node compat

Comments

@StilauGamer
Copy link

Version: Deno 2.0

What is the issue?

Basically, if you are trying to integrate Clerk with NextJS it will immediately crash when the first page is trying to compile.
It passes the middleware compilation, but when it hits the page compilation; it crashes immediately.

Note: A default NextJS application, with no Clerk added will not crash. Its when Clerk is added, it crashes.

Error that occurs upon page compilation:

error: Uncaught TypeError: Failed to decompress
    at BrotliDecompress.transform [as _transform] (ext:deno_node/_brotli.js:69:23)
    at BrotliDecompress.Transform._write (ext:deno_node/_stream.mjs:4563:12)
    at writeOrBuffer (ext:deno_node/_stream.mjs:3520:16)
    at _write (ext:deno_node/_stream.mjs:3465:14)
    at BrotliDecompress.Writable.write (ext:deno_node/_stream.mjs:3468:14)
    at Readable.ondata (ext:deno_node/_stream.mjs:2744:26)
    at Readable.emit (ext:deno_node/_events.mjs:393:28)
    at resume_ (ext:deno_node/_stream.mjs:2915:7)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:36:15)
    at runNextTicks (ext:deno_node/_next_tick.ts:75:3)
    at eventLoopTick (ext:core/01_core.js:182:21)
error: Uncaught (in promise) TypeError: Unknown signal: 0
    at toDenoSignal (ext:deno_node/internal/child_process.ts:389:11)
    at ChildProcess.kill (ext:deno_node/internal/child_process.ts:298:53)
    at handleSessionStop (file:///F:/Scripts/ClerkDenoTesting/node_modules/.deno/next@14.2.15/node_modules/next/dist/cli/next-dev.js:84:51)
    at ChildProcess.<anonymous> (file:///F:/Scripts/ClerkDenoTesting/node_modules/.deno/next@14.2.15/node_modules/next/dist/cli/next-dev.js:253:23)
    at ChildProcess.emit (ext:deno_node/_events.mjs:393:28)
    at ext:deno_node/internal/child_process.ts:277:16
    at eventLoopTick (ext:core/01_core.js:175:7)

How to reproduce?

Its quite simple to reproduce.
Just follow these small steps and you should be having the same issues:

  1. Create a new NextJS project with: deno run -A npm:create-next-app@latest and follow the setup instruction.
  2. When created, follow the default Clerk integration: https://clerk.com/docs/quickstarts/nextjs, the only thing needed from here is adding the packages, adding tokens to the .env file, adding the middleware.ts file and adding the ClerkProvider to your layout.tsx.
  3. Run up the application with: deno task dev, let it start up and try opening the page.

If you followed the instructions correctly, it should have crashed by now! :)

@marvinhagemeister marvinhagemeister added bug Something isn't working correctly node compat nextjs Issue relating to Next.js labels Oct 10, 2024
@Tauqeer-Ahmed-99
Copy link

I am also facing same issue.
Maybe something related to deno latest release.

When I unintsalled deno started working fine with npm.

CC: @marvinhagemeister

@kreindo
Copy link

kreindo commented Oct 24, 2024

same issue here too

@CaptainN
Copy link

Not sure this is related, or something completely different - from running (with sharp defined in package.json):

deno install --allow-scripts=npm:sharp

I get an error related BrotliDecompress:

Warning node-gyp was used in a script, but was not listed as a dependency. Either add it as a dependency or install it globally (e.g. `npm install -g node-gyp`)
error: script 'install' in 'sharp@0.32.6' failed with exit code 1
stdout:
sharp: Using cached /Users/kevin.newman/.npm/_libvips/libvips-8.14.5-darwin-arm64v8.tar.br
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies

stderr:
sharp: Installation error: Not implemented: BrotliDecompress.prototype.constructor
Error launching 'node-gyp': No such file or directory (os error 2)

@maxiicodes
Copy link

maxiicodes commented Oct 25, 2024

I'm also not sure if it's related, but I get the same BrotliDecompress error as @CaptainN.

Command:

deno install --allow-scripts=npm:sharp@0.32.6,npm:vue-demi@0.14.10

Error:

Warning node-gyp was used in a script, but was not listed as a dependency. Either add it as a dependency or install it globally (e.g. `npm install -g node-gyp`)
error: script 'install' in 'sharp@0.32.6' failed with exit code 1
stdout:
sharp: Using cached /var/home/maggsii/.npm/_libvips/libvips-8.14.5-linux-x64.tar.br
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies

stderr:
sharp: Installation error: Not implemented: BrotliDecompress.prototype.constructor
Error launching 'node-gyp': No such file or directory (os error 2)

error: failed to run scripts for packages: sharp@0.32.6

@teddybee
Copy link

teddybee commented Nov 20, 2024

I have the same issue with nextjs 15.0.3 and deno 2.0.6
If I remove the middleware.ts from the project, it runs.

TypeError: Failed to decompress
    at BrotliDecompress.transform [as _transform] (ext:deno_node/_brotli.js:69:23)
    at Transform._write (ext:deno_node/_stream.mjs:4563:12)
    at writeOrBuffer (ext:deno_node/_stream.mjs:3520:16)
    at _write (ext:deno_node/_stream.mjs:3465:14)
    at Writable.write (ext:deno_node/_stream.mjs:3468:14)
    at Readable.ondata (ext:deno_node/_stream.mjs:2744:26)
    at Readable.emit (ext:deno_node/_events.mjs:393:28)
    at Readable.read (ext:deno_node/_stream.mjs:2597:14)
    at flow (ext:deno_node/_stream.mjs:2933:38)
    at resume_ (ext:deno_node/_stream.mjs:2915:7)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:36:15)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:182:21)

@StilauGamer StilauGamer changed the title Issues regaring integration of Clerk with NextJS Issues regarding integration of Clerk with NextJS Nov 21, 2024
@sigmachirality
Copy link

sigmachirality commented Dec 8, 2024

Just adding a comment here to note that I'm also running into this error - app will compile without the Clerk middleware, but will not with it

@sigmachirality
Copy link

sigmachirality commented Dec 24, 2024

Hoping that #27455 will fix. Happy to test Clerk and report back when it is merged

@sarimabbas
Copy link

sarimabbas commented Dec 28, 2024

I am facing a somewhat similar issue when adding clerk middleware, not sure if related to brotli decompress:

Error: Attempt to export a nullable value for "File"
    at defineProperties (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/compiled/edge-runtime/index.js:1:513931)
    at addPrimitives (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/compiled/edge-runtime/index.js:1:512676)
    at Object.extend (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/compiled/edge-runtime/index.js:1:507116)
    at new VM (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/compiled/edge-runtime/index.js:1:514800)
    at new EdgeVM (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/compiled/edge-runtime/index.js:1:507046)
    at createModuleContext (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/web/sandbox/context.js:234:21)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async getModuleContext (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/web/sandbox/context.js:414:71)
    at async getRuntimeContext (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/web/sandbox/sandbox.js:60:44)
    at async runWithTaggedErrors (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/web/sandbox/sandbox.js:81:21)
    at async DevServer.runMiddleware (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/next-server.js:1008:24)
    at async DevServer.runMiddleware (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/dev/next-dev-server.js:270:28)
    at async NextNodeServer.handleCatchallMiddlewareRequest (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/next-server.js:330:26)
    at async DevServer.handleRequestImpl (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/base-server.js:859:28)
    at async (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/dev/next-dev-server.js:371:20)
    at async Span.traceAsyncFn (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/trace/trace.js:153:20)
    at async DevServer.handleRequest (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/dev/next-dev-server.js:368:24)
    at async handleRoute (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/lib/router-utils/resolve-routes.js:312:33)
    at async resolveRoutes (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/lib/router-utils/resolve-routes.js:554:28)
    at async handleRequest (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/lib/router-server.js:267:96)
    at async requestHandlerImpl (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/lib/router-server.js:432:13)
    at async ServerImpl.requestListener (file:///Users/johndoe/Developer/app/node_modules/.deno/next@15.1.3/node_modules/next/dist/server/lib/start-server.js:146:13)

I tried testing with the fix using your commit hash for the canary as follows but it still gave me the same error:

deno upgrade --canary --version=5194222e02d54158c47240ef78f7d3379a274eeb

Would appreciate any guidance, in case I am doing anything incorrectly 🙏

@littledivy littledivy reopened this Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly nextjs Issue relating to Next.js node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants