Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/stale-adults-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@opennextjs/cloudflare": patch
---

fix: enable using workerd process v2

process v2 is an updated version of `node:process` active by default after 2025-09-15
2 changes: 1 addition & 1 deletion examples/playground15/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "node_modules/wrangler/config-schema.json",
"main": ".open-next/worker.js",
"name": "playground15",
"compatibility_date": "2024-12-30",
"compatibility_date": "2025-09-15",
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public", "enable_request_signal"],
"assets": {
"directory": ".open-next/assets",
Expand Down
3 changes: 2 additions & 1 deletion packages/cloudflare/src/cli/build/bundle-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { inlineFindDir } from "./patches/plugins/find-dir.js";
import { patchInstrumentation } from "./patches/plugins/instrumentation.js";
import { inlineLoadManifest } from "./patches/plugins/load-manifest.js";
import { patchNextServer } from "./patches/plugins/next-server.js";
import { patchResolveCache } from "./patches/plugins/open-next.js";
import { patchResolveCache, patchSetWorkingDirectory } from "./patches/plugins/open-next.js";
import { handleOptionalDependencies } from "./patches/plugins/optional-deps.js";
import { patchPagesRouterContext } from "./patches/plugins/pages-router-context.js";
import { patchDepdDeprecations } from "./patches/plugins/patch-depd-deprecations.js";
Expand Down Expand Up @@ -107,6 +107,7 @@ export async function bundleServer(buildOpts: BuildOptions, projectOpts: Project
patchRouteModules(updater, buildOpts),
patchDepdDeprecations(updater),
patchResolveCache(updater, buildOpts),
patchSetWorkingDirectory(updater, buildOpts),
// Apply updater updates, must be the last plugin
updater.plugin,
] as Plugin[],
Expand Down
29 changes: 29 additions & 0 deletions packages/cloudflare/src/cli/build/patches/plugins/open-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,32 @@ rule:
fix: |-
var composableCacheHandlerPath = "";
`;

export function patchSetWorkingDirectory(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
const { outputDir } = buildOpts;
const packagePath = getPackagePath(buildOpts);
const outputPath = path.join(outputDir, "server-functions/default");

const indexPath = path.relative(
buildOpts.appBuildOutputPath,
path.join(outputPath, packagePath, `index.mjs`)
);

return updater.updateContent("do-not-set-working-directory", [
{
filter: getCrossPlatformPathRegex(indexPath),
contentFilter: /function setNextjsServerWorkingDirectory\(/,
callback: async ({ contents }) => patchCode(contents, workingDirectoryRule),
},
]);
}

// `setNextjsServerWorkingDirectory` calls `process.chdir("")` which errors because the directory does not exists
// See https://github.com/opennextjs/opennextjs-cloudflare/issues/899
export const workingDirectoryRule = `
rule:
pattern: function setNextjsServerWorkingDirectory() { $$$BODY }
fix: |-
function setNextjsServerWorkingDirectory() {
}
`;