Skip to content

[v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets" when bundling with Webpack #3452

Closed
@andrew-pledge-io

Description

@andrew-pledge-io

After upgrading to 8.15.0, bundling with Webpack results in the following error:

Webpack compilation failed:
in cloudflare:sockets
  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.

This previously occurred in version 8.11.0: #2975

And was fixed in this PR: #2978

Activity

changed the title [-][v8.15.0] Regression: UnhandledSchemeError when bundling with Webpack[/-] [+][v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets " when bundling with Webpack[/+] on May 1, 2025
changed the title [-][v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets " when bundling with Webpack[/-] [+][v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets" when bundling with Webpack[/+] on May 1, 2025
CHC383

CHC383 commented on May 1, 2025

@CHC383
Contributor

As noted in #2978, the temporary workarounds would be:

webpack.config.js

  plugins: [
    new webpack.IgnorePlugin({
      resourceRegExp: /^cloudflare:sockets$/,
    }),
  ],

next.config.ts

  webpack: (config, { webpack }) => {
    config.plugins.push(
      new webpack.IgnorePlugin({
        resourceRegExp: /^cloudflare:sockets$/,
      }),
    );
    return config;
  },
brianc

brianc commented on May 1, 2025

@brianc
Owner

hmmm thanks for the info! Any idea on the right fix here? I wonder if I should write a test by trying to webpackify everything in a separate module in the repo & see if it works?

CHC383

CHC383 commented on May 2, 2025

@CHC383
Contributor

@brianc If you are okay with the conditional exports as the previous version, how about using nested conditions? Something like:

  "exports": {
    ".": {
      "cloudflare": {
        "import": "./esm/index.mjs",
        "require": "./dist/index.js",
      }
      "default": "./dist/empty.js"
    }
  },

And users of Cloudflare Workers need to explicitly enable the conditions in their webpack configs.

Or another option might be move (to dev)/remove the dependency pg-cloudflare, and users need to explicitly add it as a dependency in their package.json.

cjnoname

cjnoname commented on May 10, 2025

@cjnoname

We're experiencing the same issue. Is there a better solution for this?

willr42

willr42 commented on May 11, 2025

@willr42

Also experiencing this. Is there a workaround for Vite?

ghardin1314

ghardin1314 commented on May 13, 2025

@ghardin1314

Also having the same regession with vite. The last working resolved version is pg-cloudflare@1.1.1. Any version after this breaks my build. I also cant figure out how to force pnpm to resolve to this version for pg package dependencies. I have to manually go into my pnpm-lock.yaml file and revert back to the 1.1.1 resolution any time I make dependency updates.

brianc

brianc commented on May 13, 2025

@brianc
Owner

I'm open to a PR to fix this....particularly if there's a test included to reproduce it, though that's not required.

josuazurbruegg

josuazurbruegg commented on Jun 1, 2025

@josuazurbruegg

Also having the same regession with vite. The last working resolved version is pg-cloudflare@1.1.1. Any version after this breaks my build. I also cant figure out how to force pnpm to resolve to this version for pg package dependencies. I have to manually go into my pnpm-lock.yaml file and revert back to the 1.1.1 resolution any time I make dependency updates.

I was struggling with this for a bit today as well. It seems pnpm overrides dependencies at the root level in a monorepo (makes sense, I guess) and overrides needs to be specified differently. Both of the following worked for me:

In pnpm-workspace.yaml:
overrides: pg-cloudflare: 1.1.1

and in root package.json:
"pnpm": { "overrides": { "pg-cloudflare": "1.1.1" } },

CHC383

CHC383 commented on Jun 4, 2025

@CHC383
Contributor

While waiting for #3482, if you need a temporary workaround to allow/ignore cloudflare:sockets for webpack/vite/rollup instead of reverting pg-cloudflare to 1.1.1, please check the tests or README in #3482.

Basically the configs to handle cloudflare:sockets would be needed whenever pg-cloudflare is enabled while using some bundlers. Right now pg-cloudflare is enabled by default, and after #3482 it will be enabled through resolve conditions.

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

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @brianc@CHC383@josuazurbruegg@cjnoname@willr42

      Issue actions

        [v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets" when bundling with Webpack · Issue #3452 · brianc/node-postgres