Abhishek
Abhishek6d ago

Clerk installation failing with convex

I am updating my clerk and nextjs application and getting this error ⠙ Bundling component schemas and implementations... ✘ [ERROR] Could not resolve "node:async_hooks" node_modules/@clerk/nextjs/dist/esm/server/middleware-storage.js:2:34: 2 │ import { AsyncLocalStorage } from "node:async_hooks"; ╵ ~~~~~~~~~~~~~~~~~~ The package "node:async_hooks" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. ✖ It looks like you are using Node APIs from a file without the "use node" directive. See https://docs.convex.dev/functions/runtimes#nodejs-runtime Any solution on this ?
22 Replies
Convex Bot
Convex Bot6d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart5d ago
Any chance you're unintentionally importing from your node middleware in a convex runtime function, somewhere up the chain? Often happens when code is shared between the two
Abhishek
AbhishekOP5d ago
I'm importing from the clerk- backend
erquhart
erquhart5d ago
Ah you said this was due to an update, missed that. Figured it out?
Abhishek
AbhishekOP4d ago
Nope sadly I think I will revert back
erquhart
erquhart4d ago
Oh this post has a resolved tag (I can’t remove it on mobile) - can you help me reproduce? Which packages were updated and from what version to what version
Abhishek
AbhishekOP4d ago
Sure here are package version "@clerk/clerk-react": "^5.28.0", "@clerk/nextjs": "^6.15.0", "next": "^15.3.0", "convex": "^1.23.0",
Abhishek
AbhishekOP4d ago
and cors errror
No description
Abhishek
AbhishekOP4d ago
and in console 8038-a1d4988aef7a7e7d.js:11 Error: ClerkJS: Network error at "https://clerk.superlinkify.com/v1/environment?__clerk_api_version=2025-04-10&_clerk_js_version=5.61.1" - TypeError: Failed to fetch (clerk.superlinkify.com). Please try again. at r (clerk.browser.js:1:2350) at Object.o [as request] (clerk.browser.js:1:173965) at async d._baseFetch (clerk.browser.js:1:9358) at async c.execute (clerk.browser.js:1:7723) at async o._baseGet (clerk.browser.js:1:10985) at async Promise.all (/index 0) at async tr.value (clerk.browser.js:1:165816) at async tr.load (clerk.browser.js:1:132654) at async e.loadClerkJS (4861-baf8d794f8c5cb6d.js:11:43728)
Abhishek
AbhishekOP4d ago
Also @erquhart if you need more on cors error you can visit my prod url https://superlinkify.com/
Superlinkify
LinkedIn Automation & LinkedIn AI Tool | Superlinkify - Automate Po...
Streamline your LinkedIn presence with Superlinkify. Our AI-powered tool automates post creation, campaign management, and content generation, helping you stay ahead of the game without the hassle of ghostwriting. Effortlessly generate engaging content and amplify your brand's reach on LinkedIn.
erquhart
erquhart4d ago
Is the cors error also happening on upgrade? @Abhishek let me know when you're online and can answer some questions. I can't tell if this used to work and an upgrade broke it, it sounds like you're installing Clerk to an application that was not using it prior. Clerk says in a related support post that they don't support authenticating from middleware this way: https://discord.com/channels/856971667393609759/1311517760131694592
Abhishek
AbhishekOP4d ago
Hi @erquhart yes this same application was working fine and I am encountering this only after upgrade All the api keys and domain is same nothing has change also clerk is working fine locally
erquhart
erquhart4d ago
and you're authenticating from middleware right? any code you can share? The cors error is because a sentry-trace header is now present in the request and it isn't on the allowed headers list Did you enable sentry by chance I'm not sure why the node import is happening after upgrade, but understanding what you're doing more will help: - where are you importing nextjs middleware auth code in your Convex functions - what versions are you upgrading from - have you enabled sentry (cors issues)
Abhishek
AbhishekOP4d ago
Yes sentry is enabled
erquhart
erquhart4d ago
okay, and what versions are you upgrading from and was sentry enabled before the upgrade?
Abhishek
AbhishekOP4d ago
Yes it was but it was also a older version let me quickly get git history @sentry/nextjs": "^7.114.0", ----> "@sentry/nextjs": "^9.13.0", "next": "^14.2.25", -----> "next": "^15.3.0", "@clerk/clerk-sdk-node": "^4.13.20", -------> "@clerk/nextjs": "^6.15.0", "@clerk/nextjs": "^4.29.6",
erquhart
erquhart4d ago
Yeah upgrading across multiple major releases, in multiple packages, will probably bring breaking changes. Did you walk through migration guides for each? From a Convex standpoint, node code is being run in the Convex runtime, but you'll need to do some troubleshooting to see what changed in your codebase. I'd first follow migration guides for all of this. After that: For cors, I'd check for headers in these sentry requests while downgraded and then while upgraded to see if the headers were always present. Clerk may be able to offer some insight in their discord as well as it's hitting their domain. For the node error you'll want to track down exactly where the node imports are coming from in your code, and then I'd again compare downgraded vs upgraded, clicking through to source in your ide for each, to see what's changed, and maybe how your new code should adapt. Hopefully following migration steps will be enough, though.
Abhishek
AbhishekOP3d ago
Fixed it thanks @erquhart , So, anyone having the problem just do this. In Sentry configuration keep tracePropagationTargets as an empty array tracePropagationTargets: [ ],
erquhart
erquhart3d ago
So glad you got it sorted! That fixed the node runtime error too?
Abhishek
AbhishekOP3d ago
Node runtime was fixed, I was using old depricated function of clerk which is why it was failing
erquhart
erquhart3d ago
Ah okay 👍

Did you find this page helpful?