Skip to content

Commit ab896a1

Browse files
denolfekendelljoseph
authored andcommitted
fix(next): pg-cloudflare build issue (#12242)
Fixes next build issue related to `cloudflare:sockets`. Related Next.js discussion thread here: vercel/next.js#50177 Commands to recreate issue locally ```sh pnpm run script:pack --dest templates/with-postgres && \ pnpm run script:build-template-with-local-pkgs with-postgres postgresql://localhost:5432/payloadtests ``` **Build Error:** ``` Failed to compile. 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. at /home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:29:408376 at Hook.eval [as callAsync] (eval at create (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:14:9224), <anonymous>:6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:14:6378) at Object.processResource (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:29:408301) at processResource (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308) at iteratePitchingLoaders (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667) at runLoaders (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590) at NormalModule._doBuild (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:29:408163) at NormalModule.build (/home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:29:410176) at /home/runner/work/payload/payload/templates/with-postgres/node_modules/.pnpm/next@15.3.0_react-dom@19.1.0_react@19.1.0__react@19.1.0_sass@1.77.4/node_modules/next/dist/compiled/webpack/bundle5.js:29:82494 ```
1 parent 1115ef2 commit ab896a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/next/src/withPayload.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ export const withPayload = (nextConfig = {}, options = {}) => {
140140
{ module: /node_modules\/mongodb\/lib\/bson\.js/ },
141141
{ file: /node_modules\/mongodb\/lib\/bson\.js/ },
142142
],
143+
plugins: [
144+
...(incomingWebpackConfig?.plugins || []),
145+
// Fix cloudflare:sockets error: https://github.com/vercel/next.js/discussions/50177
146+
new webpackOptions.webpack.IgnorePlugin({
147+
resourceRegExp: /^pg-native$|^cloudflare:sockets$/,
148+
}),
149+
],
143150
resolve: {
144151
...(incomingWebpackConfig?.resolve || {}),
145152
alias: {

0 commit comments

Comments
 (0)