porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.42k stars 271 forks source link

cloudflare:sockets import error #711

Closed maxifom closed 11 months ago

maxifom commented 11 months ago

I was using https://github.com/t3-oss/create-t3-turbo to create app. It uses drizzle and planetscale, i changed it to use postgres, but it gives error

ModuleBuildError: Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.
    at /home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:28:399825
    at Hook.eval [as callAsync] (eval at create (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:13:28867), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:13:26021)
    at Object.processResource (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:28:399750)
    at processResource (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:28:399612)
    at NormalModule.build (/home/max/WebstormProjects/turbo-openfinance/node_modules/next/dist/compiled/webpack/bundle5.js:28:401640)

because of await import ("cloudflare:sockets") in polyfilles. Any ideas how to fix it?

Github repo with steps to reproduce: https://github.com/maxifom/postgresjs-bug

maxifom commented 11 months ago

Similar issue https://github.com/brianc/node-postgres/pull/2978

porsager commented 11 months ago

You should take it up with the bundler picking the wrong export.

vincelwt commented 10 months ago

Also seeing this with a base Next.js 14 app in dev

rikurainio commented 10 months ago

same issue on Next.js 14 dev