Skip to content

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Sep 23, 2025

fixes #899

node:process has a new implementation in workerd ("v2" enabled by default on 2025-09-15).
v2 supports process.chdir() so it now errors when a non existent directory is passed (the cloudflare adapter passes "").
(The unenv implementation used before was a no-op).

Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: a5cb01d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Sep 23, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@903

commit: a5cb01d

Copy link
Collaborator

@sommeeeer sommeeeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good job on the fast fix

Copy link
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work, but I don't think this is the right fix. We should not patch things in aws here, at least not like that.
We should use this plugin https://github.com/opennextjs/opennextjs-aws/blob/main/packages/open-next/src/plugins/replacement.ts and just add an #override around it in aws

@vicb
Copy link
Contributor Author

vicb commented Sep 23, 2025

It does work, but I don't think this is the right fix. We should not patch things in aws here, at least not like that. We should use this plugin https://github.com/opennextjs/opennextjs-aws/blob/main/packages/open-next/src/plugins/replacement.ts and just add an #override around it in aws

I agree it's not ideal and we should improve this.
One way would be to pass additionalCodePatches to createServerBundle and use the replacement plugin.
But:

  • cloudflare already has its own version of createServerBundle
  • having AWS specific code in the "common" code base is not the best thing either

So let's merge this PR as is for now and think about a better way to support "common" + variants when we work on the adapters API.

WDYT?

Copy link
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So let's merge this PR as is for now and think about a better way to support "common" + variants when we work on the adapters API.
WDYT?

That's fine by me, but I still prefer the #override solution with the additionalCodePatches

What i really don't like about this one is that there is no way to know from the aws repo that we are modifying this function somewhere else. Very easy to forget about it and break a release this way

@vicb
Copy link
Contributor Author

vicb commented Sep 23, 2025

So let's merge this PR as is for now and think about a better way to support "common" + variants when we work on the adapters API.
WDYT?

That's fine by me, but I still prefer the #override solution with the additionalCodePatches

What i really don't like about this one is that there is no way to know from the aws repo that we are modifying this function somewhere else. Very easy to forget about it and break a release this way

Agreed.

Hopefully we don't add more than what the setNextjsServerWorkingDirectory name says in this function. Also this is e2e tested in playground15.

I have create this issue to improve the current PR but let's merge this now to avoid new projects fail build for now.

@vicb
Copy link
Contributor Author

vicb commented Sep 23, 2025

Thanks all for the review and feedback.

As the comments say, we should improve the current implementation but I'll merge this to avoid breaking new projects.

@vicb vicb merged commit 7fced0f into main Sep 23, 2025
7 checks passed
@vicb vicb deleted the vicb/process branch September 23, 2025 18:46
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

Successfully merging this pull request may close these issues.

[BUG] OpenNext AWS adapter code is included in Cloudflare bundle, breaking request serving at runtime
4 participants