Skip to content

[NOT A DRIVER BUG] Bundlers fail on cloudflare:sockets imports in Next.js and other builds that never target Workers #71

Closed as not planned

Description

@okomarov

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.

Activity

  1. added
    bug
    area: runtimes
    upstream
    on Oct 16, 2026
  2. moved this to Next in Roadmapon Oct 16, 2026
  3. okomarov commented on Oct 18, 2026

    @okomarov
    Author

    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).

  4. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: runtimesbugupstream

    Type

    No type

    Projects

    • Status
      Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions