Closed AlonMiz closed 4 months ago
Hello @AlonMiz , thanks for the report.
It looks like something prevents tree-shaking from working when next builds the server modulel. I'd like to ask a few questions that will help the team further debug this one:
@clerk/nextjs
or @clerk/nextjs/server
? Could you try importing from /server
and see if that resolves your issue?--turbo
flag?It'd be great if you could share a minimum reproduction as you are using many different libs (Clerk, tRPC, Next, Turbo) that could affect how modules are resolved.
Thank you!
I experienced the same issue when updating to next@14.2.0 when importing from @clerk/nextjs
in api route handlers.
My exact setup did work with next@14.1.4 using the --turbo
flag.
I can confirm that both solutions mentioned by @nikosdouvlis:
importing from @clerk/nextjs/server
in api route handlers,
or removing the --turbo
flag,
along with both solutions combined, resolved the error in my use case.
just a note here, I had the same on a simple project, without trpc. (so just 14.2, clerk + turbo ). i confirmed it only happens when you --turbo
Hello @AlonMiz , thanks for the report.
It looks like something prevents tree-shaking from working when next builds the server modulel. I'd like to ask a few questions that will help the team further debug this one:
- In the file that throws the error, are you importing the Clerk helpers from
@clerk/nextjs
or@clerk/nextjs/server
? Could you try importing from/server
and see if that resolves your issue?- Does this work if you switch to webpack by removing the
--turbo
flag?- Did your exact setup work with next@14.1?
It'd be great if you could share a minimum reproduction as you are using many different libs (Clerk, tRPC, Next, Turbo) that could affect how modules are resolved.
Thank you!
/server
doesn't helpIs there any progress on this issue? We've encountered numerous problems with Clerk since upgrading to App Router over the past few months. Due to these ongoing issues, we are starting to seriously consider other alternatives on the market.
Additionally, I've verified that appending /server to the configuration does not resolve the issue. I also attempted to upgrade to Clerk Core 2 Beta, but we continue to face the same challenges. Although removing the --turbo flag does mitigate the problem, it significantly increases our page load times by several seconds, which is not a viable solution for us.
@DennizSvens would you be able to email support@clerk.dev with some of the other problems you're running into with Clerk and App Router? You can reference this issue and we'll follow up.
Unfortunately no updates on this specific issue yet. We'll provide an update when someone from the team has started investigating. We know --turbo is a significant performance improvement to Next's dev server, so we want to make sure Clerk works with it when turbo is stable. 🙏
UPDATE latest clerk + latest next js does compile (seems like turbopack fixed something on their side)
"@clerk/clerk-sdk-node": "5.0.0",
"@clerk/nextjs": "5.0.1",
"@clerk/themes": "2.0.0",
"next": "14.2.2",
Hello @AlonMiz ,
Why do you use both "@clerk/clerk-sdk-node"
and "@clerk/nextjs"
?
Hello @AlonMiz , Why do you use both
"@clerk/clerk-sdk-node"
and"@clerk/nextjs"
?
great question
i needed some types, specifically
RedirectUrlJSON
and Organization
that I couldn't find easily in @clerk/nextjs
now I also notice that there's no clerkClient in the next js package :/ so this would probably be a pretty bad for me loading those two bundles
also, I have another issue now working with cypress https://github.com/clerk/example-cypress-nextjs/issues/7
Hello @AlonMiz , Why do you use both
"@clerk/clerk-sdk-node"
and"@clerk/nextjs"
?great question i needed some types, specifically
RedirectUrlJSON
andOrganization
that I couldn't find easily in@clerk/nextjs
now I also notice that there's no clerkClient in the next js package :/ so this would probably be a pretty bad for me loading those two bundlesalso, I have another issue now working with cypress clerk/example-cypress-nextjs#7
You can now import the Organization
from the @clerk/nextjs/server
. What is your use case related to the RedirectUrlJSON
?
About the cypress issue we will investigate it and reply in the related GH issue.
UPDATE latest clerk + latest next js does compile (seems like turbopack fixed something on their side)
"@clerk/clerk-sdk-node": "5.0.0", "@clerk/nextjs": "5.0.1", "@clerk/themes": "2.0.0", "next": "14.2.2",
v5 is basically a whole new Core, and as such not everyone will want to use it. Is there not a backport fix for the v4 line ?
Hello @AlonMiz , Why do you use both
"@clerk/clerk-sdk-node"
and"@clerk/nextjs"
?great question i needed some types, specifically
RedirectUrlJSON
andOrganization
that I couldn't find easily in@clerk/nextjs
now I also notice that there's no clerkClient in the next js package :/ so this would probably be a pretty bad for me loading those two bundles also, I have another issue now working with cypress clerk/example-cypress-nextjs#7You can now import the
Organization
from the@clerk/nextjs/server
. What is your use case related to theRedirectUrlJSON
?About the cypress issue we will investigate it and reply in the related GH issue.
thanks, I hope this gets fixed soon, as I was planning to upgrade the core API already.
regarding the RedirectUrlJSON, I am creating an actor token for impersonation. and I couldn't find the return type that matches
const res = await fetch('https://api.clerk.com/v1/actor_tokens', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${env.CLERK_SECRET_KEY}`,
},
body: JSON.stringify({
user_id: userIdToImpersonate,
expires_in_seconds: 600,
actor: {
sub: userId,
},
}),
});
const actorToken = (await res.json()) as RedirectUrlJSON;
Hi!
I'm closing this again since the original issue got fixed / fixed itself. In order to properly track your request and others we must make sure that issues are not mixed together and multiple people are not talking about different things in a singular issue. It also makes it harder to actually fix in the end since things like minimal reproductions are missing again.
Please open a new issue about your type issues. Thanks!
Preliminary Checks
Reproduction
not yet
Publishable key
pk_test_cHJvcGVyLXNwYXJyb3ctNDkuY2xlcmsuYWNjb3VudHMuZGV2JA
Description
Steps to reproduce:
Expected behavior:
would not expect the usage of context in a server route. there's shouldn't be a 'use client' as this is a pure API route
Actual behavior:
erroring on every trpc route
Environment