-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Doesn't work with next.js Edge runtime #3206
Comments
Yeah it would probably...how does one reproduce this issue locally? If running in node then |
Set up a basic And then assume to use CloudFlare Pages requires a next.js app to specify that all backend endpoints will be using the edge runtime. There's a further complication that |
I am trying to use Prisma, PrismaPg and Pg.
Call Stack
https://vercel.com/docs/functions/runtimes/edge-runtime#unsupported-apis I know it's not really an issue related to Pg but I wanted to inform here anyway. |
I am using Next.js and Drizzle, and get the same: |
This patch fixes for me. Specifically: prevents the error
diff --git a/node_modules/pg/lib/crypto/utils-webcrypto.js b/node_modules/pg/lib/crypto/utils-webcrypto.js
index 0433f01..588066e 100644
--- a/node_modules/pg/lib/crypto/utils-webcrypto.js
+++ b/node_modules/pg/lib/crypto/utils-webcrypto.js
@@ -13,7 +13,10 @@ module.exports = {
* The Web Crypto API - grabbed from the Node.js library or the global
* @type Crypto
*/
-const webCrypto = nodeCrypto.webcrypto || globalThis.crypto
+
+// PATCH: Don't break under Next.js Edge runtime production build
+const webCrypto = ("webcrypto" in nodeCrypto ? nodeCrypto.webcrypto : undefined) ?? globalThis.crypto
+
/**
* The SubtleCrypto API for low level crypto operations.
* @type SubtleCrypto (I opted to use runtime-agnostic Feature Detection for |
I'm writing an app on
next.js
which I plan to deploy to CloudFlare Pages + Workers. I know there's CloudFlare support, but when running the local development server of next.js, I get the following errors:Would it make sense to generalize CloudFlare Workers detection into a broader Edge detection that also includes node edge runtime?
The text was updated successfully, but these errors were encountered: