Closed MedicusIO closed 1 year ago
Thanks for reporting that. A ticket for this issue already exists, so let me get back at you once the fix is deployed - will probably happen soon enough :)
Hey @MedicusIO :) Can you please gives us some information on your setup and the packages used ? (an example repo would be even better)
After much soul searching I switched to Fly.IO which runs node (so this is less of an issue to me now). Cloudflare workers run V8 so anything that runs in the browser runs in a worker. The upside is there is no cold start like with lambda. However, you cannot use any node packages which is limiting.
I've encountered this too I think, even just trying to run miniflare with Clerk doesn't seem to work.
I'm guessing it's because of Clerk only because of this error:
../../node_modules/http2-wrapper/source/index.js:2:22:
2 │ const http2 = require('http2');
╵ ~~~~~~~
The package "http2" 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.
If I search through all the packages in the project for the ones that use http-wrapper, the only one I get is one called "got", which is used in Clerk-node. I'll try and put together a simple reproduction case but it might take until this weekend.
Thanks peeps, it would be really helpful for us to start checking the issue based on the setup and give you a resolution.
Found five minutes this morning and it was actually easier than I thought to reproduce. https://github.com/Slooowpoke/clerk-remix-workers
This is a fresh remix repo with Cloudflare workers set as the deployment target, I've added Clerk's root auth loader, nothing else. If you try to run this, it won't work. If you remove the two lines for Clerk from root.tsx it works. Hope that's helpful.
clerk-remix
depends on clerk-node-sdk
that uses got HTTP client. That is, the current version of clerk-remix
works for Node runtimes. I will a PR later today using a cross fetch library.
any update here?
Still working on it. The latest status is that we need to find an isomorphic HTTP clients and an isomorphic crypto library. The HTTP client we picked for now is cross-fetch. Things are a bit trickier in the crypto world.
Thanks for the update! Not sure if this helps, but CF workers implements the web crypto api and there seems to be something similar to cross-fetch for that use case. https://www.npmjs.com/package/isomorphic-webcrypto
There also seems to be support for the web crypto API in node directly but the earliest LTS with support seems to be 16 https://nodejs.org/api/webcrypto.html#web-crypto-api
+1 this is also blocking me. Anything we can do to help speed up the process?
Thanks for the update! Not sure if this helps, but CF workers implements the web crypto api and there seems to be something similar to cross-fetch for that use case. https://www.npmjs.com/package/isomorphic-webcrypto
There also seems to be support for the web crypto API in node directly but the earliest LTS with support seems to be 16 https://nodejs.org/api/webcrypto.html#web-crypto-api
According to MDN, it's supported from v15.
Folks, this is the first PR towards a more isomorphic architecture https://github.com/clerkinc/javascript/pull/290. It's still WIP as I am currently on paternity leave but the direction should be clear. Let us know what you think.
@SokratisVidros any updates or any way to help speed up the process?
Still working on it. The latest status is that we need to find an isomorphic HTTP clients and an isomorphic crypto library. The HTTP client we picked for now is cross-fetch. Things are a bit trickier in the crypto world.
There's https://github.com/sindresorhus/ky-universal by the same people who created got.
Hey @marcus-sa, the PR introducing fetch will be merged later this week. The next step is to bump to Node 16 and use webcrypto. Apologies this is taking longer than expected but more pressuring tasks came up as we are in the process of releasing ClerkJS V4 with brand new components.
The first PR about fetch is now merged. Next week we will replace Node crypto with Web crypto.
Any update on this? Would be good to be finally able use Clerk with Remix and CF Pages. 🙏
Apologies for the delay. We are currently working to support Next.js 12.2 Middleware. Cloudflare workers for Remix and other frameworks are next on the list.
Is there any sort of timeline that we could refer to?
We expect this to be resolved in November. As you can see in https://github.com/clerkinc/javascript/pull/460/files we've started rearchitecting our backend SDKS to make them work across web-interoperable runtimes.
@SokratisVidros May I know the status of this ? Is the support for Remix on Cloudflare workers is still experimental ?
@dimkl Thank you for tagging this to my comment but I am afraid and believe that these are not related. The document on your website clearly states that Edge runtime including Cloudflare Workers is supported https://clerk.com/docs/quickstarts/get-started-with-remix
I am not sure if this ticket is still valid. Please kindly help this is a huge blocker for the work which I have planned. Thank you so much in advance.
I am currently using Clerk plus Cloudflare Pages so I believe this can be closed
Yes, Remix is fully supported across all runtimes.
@aerojeyenth your issue is not related to this. i will reopen the previous issue.
Package
@clerk/clerk-js
@clerk/clerk-react
@clerk/nextjs
@clerk/remix
@clerk/clerk-expo
@clerk/backend-core
@clerk/clerk-sdk-node
@clerk/edge
Description
The rootAuthLoader uses http2 which is a node package. Cloudflare Workers does not have access to Node.js packages, just plain javascript. Can this not be changed to fetch?