Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andrew-pledge-io opened this issue May 1, 2025 · 3 comments

Comments

@andrew-pledge-io
Copy link

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

@andrew-pledge-io andrew-pledge-io changed the title [v8.15.0] Regression: UnhandledSchemeError when bundling with Webpack [v8.15.0] Regression: UnhandledSchemeError "cloudflare:sockets " when bundling with Webpack May 1, 2025
@andrew-pledge-io andrew-pledge-io 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 May 1, 2025
@CHC383
Copy link

CHC383 commented May 1, 2025

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
Copy link
Owner

brianc commented May 1, 2025

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
Copy link

CHC383 commented May 2, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants