Postgres.js not working in next.js

⨯ Error: The edge runtime does not support Node.js 'perf_hooks' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
at Object.get (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_next_dist_esm_server_web_969587._.js:59:19)
at createSocket (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:808:228)
at Timeout.connect [as _onTimeout] (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:962:35)
at cachedError (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:151:25)
at new Query (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:39:79)
at sql (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:1833:67)
at test (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\[root of the server]__a2200c._.js:2333:171)
⨯ Error: The edge runtime does not support Node.js 'perf_hooks' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
at Object.get (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_next_dist_esm_server_web_969587._.js:59:19)
at createSocket (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:808:228)
at Timeout.connect [as _onTimeout] (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:962:35)
at cachedError (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:151:25)
at new Query (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:39:79)
at sql (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\node_modules_postgres_src_b4bde1._.js:1833:67)
at test (D:\survivalytics\my-next-app\.next\server\edge\chunks\ssr\[root of the server]__a2200c._.js:2333:171)
wrangler.toml
compatibility_date = "2024-09-22"

compatibility_flags = ["nodejs_compat_v2"]
compatibility_date = "2024-09-22"

compatibility_flags = ["nodejs_compat_v2"]
3 Replies
Rastislav₡ore
Rastislav₡ore3mo ago
If you raise compatibility day then nodejs_compat = nodejs_compat_v2 as stated in the documentation. Then this is not needed anymore, but this is just minor improvement. I am facing same error as you in SvelteKit, then seems like it is serious error on Cloudflare. Even support ticket is w/o any reaction for week. You will be probably blocked as I am till Cloudflare will react. I am dedicated to send help to the community as soon as I will get reply.
Nob
NobOP2mo ago
I self hosted my website on my own servers because of the many problems of cloudflare pages
Rastislav₡ore
Rastislav₡ore2mo ago
Yes that is an ideal workaround. Unfortunately Cloudflare is offering malfunctioning services such as Hyperdrive (I am paying for it) and I cannot use it. I don't have any reply from support till now. I will try deploy it to alternative less pathetic services. Shame because I liked Cloudflare till now... I am not sentimental but the lack of action in my (our) case is frustrating. Reply from the Cloudflare support: Please consider the following recommendations: 1. Change the NODE_VERSION to v18. 2. Set the compatibility date to the current date. @Nob let me know if that is working for you.
Want results from more Discord servers?
Add your server