You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[NOT A DRIVER BUG] Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers #71
Builds that never deploy to Cloudflare fail on cloudflare:sockets: porsager#810 (23 reactions), porsager#822 (13), porsager#781 (10), porsager#930 (9). The largest reaction cluster upstream; it hits Next.js and Drizzle users.
First step: find which exports condition sends those bundlers to cf/polyfills.js. Possibly a cheap package.json fix, ahead of #15.
Not reproducible on current Next.js with any version, and not fixable in the driver
Run 39149154666 builds a minimal Next.js 16.4.2 app whose edge route (export const runtime = 'edge', with Drizzle) and middleware import the driver. Matrix: upstream 3.4.4, upstream 3.4.9 and @steadybrew/postgresjs 4.5.1, each with webpack and Turbopack.
No combination reports a cloudflare: scheme error.
With webpack, all three fail the same way: Module not found: Can't resolve 'net' (and tls, crypto, stream) from src/connection.js. Turbopack compiles all three.
The original cause was the worker export condition in 3.4.3 and 3.4.4, which Next.js's edge compiler matched, sending it to the Workers build and its cloudflare:sockets import. Upstream 3.4.5 renamed it to workerd, which only Cloudflare's tooling matches; this fork never exported worker. What remains is not a packaging bug: the Next.js edge runtime (edge routes and edge middleware) has no TCP sockets, so no PostgreSQL wire-protocol driver can run there. Use the Node.js runtime for routes and middleware that query the database, or an HTTP-based driver. That goes into the Cloudflare and serverless docs (#15, #12).
changed the title [-]Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers[/-][+][NOT A DRIVER BUG] Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers[/+]on Oct 18, 2026
Activity
okomarov commentedon Oct 18, 2026
Not reproducible on current Next.js with any version, and not fixable in the driver
Run 39149154666 builds a minimal Next.js 16.4.2 app whose edge route (
export const runtime = 'edge', with Drizzle) and middleware import the driver. Matrix: upstream 3.4.4, upstream 3.4.9 and @steadybrew/postgresjs 4.5.1, each with webpack and Turbopack.cloudflare:scheme error.Module not found: Can't resolve 'net'(andtls,crypto,stream) fromsrc/connection.js. Turbopack compiles all three.The original cause was the
workerexport condition in 3.4.3 and 3.4.4, which Next.js's edge compiler matched, sending it to the Workers build and itscloudflare:socketsimport. Upstream 3.4.5 renamed it toworkerd, which only Cloudflare's tooling matches; this fork never exportedworker. What remains is not a packaging bug: the Next.js edge runtime (edge routes and edge middleware) has no TCP sockets, so no PostgreSQL wire-protocol driver can run there. Use the Node.js runtime for routes and middleware that query the database, or an HTTP-based driver. That goes into the Cloudflare and serverless docs (#15, #12).[-]Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers[/-][+][NOT A DRIVER BUG] Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers[/+]