Skip to content
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

🐛 BUG: wrangler pages deploy throws misleading error when experimental:nodejs_compat_v2 is enabled #6288

Closed
irvinebroque opened this issue Jul 18, 2024 · 5 comments · Fixed by #6511 or #6549
Labels
bug Something that isn't working pages Relating to Pages

Comments

@irvinebroque
Copy link
Contributor

irvinebroque commented Jul 18, 2024

Which Cloudflare product(s) does this pertain to?

Wrangler

What version(s) of the tool(s) are you using?

3.57.1

What version of Node are you using?

v22.3.0

What operating system and version are you using?

Mac Sonoma 14.5

Describe the Bug

How to reproduce

Repro

With experimental:nodejs_compat_v2, run wrangler pages deploy...

✘ [ERROR] Could not resolve "fs"

    ../build/server/index.js:6:15:
      6 │ import fs from "fs";
        ╵                ~~~~

  The package "fs" wasn't found on the file system but is built into node.
  Add the "nodejs_compat" compatibility flag to your Pages project and make sure to prefix the module name with "node:" to enable Node.js compatibility.

This error isn't right — I already have experimental:nodejs_compat_v2 enabled, but it's telling me I need to enable the nodejs_compat flag.

If I add the node: specifier to fs, I get a different error

✘ [ERROR] Deployment failed!

  Failed to publish your Function. Got error: No such compatibility flag:
  experimental:nodejs_compat_v2

But to the customer — that's what you told me in your docs I was supposed to enable :)

Effectively — we're just returning the same error we'd return if you enabled nodejs_compat (link to repro)

What should we do about it?

When I run wrangler pages deploy with experimental:nodejs_compat_v2...

  1. The nodejs_compat_v2 compat flag should be enabled (and the experimental: prefix properly removed, as is already current behavior for Workers)
  2. No polyfills should be added to the Worker (I am assuming that it is not viable to add unenv to an already bundled Pages project — that the addition of unenv needs to be handled by the framework. If that's not the case, let me know!)

Please provide a link to a minimal reproduction

irvinebroque/remix-d1#8

Please provide any relevant error logs

No response

@irvinebroque irvinebroque added the bug Something that isn't working label Jul 18, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jul 18, 2024
@CarmenPopoviciu CarmenPopoviciu added the pages Relating to Pages label Jul 19, 2024
@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Jul 19, 2024

hi @irvinebroque

I literally ran into this myself last night, so can confirm this is indeed happening. Will take a look!

To clarify...this works as intended for Workers, just not for Pages

@irvinebroque
Copy link
Contributor Author

@CarmenPopoviciu — is this still something you're digging into?

@CarmenPopoviciu
Copy link
Contributor

@irvinebroque yes, planning to this week!

@penalosa
Copy link
Contributor

@CarmenPopoviciu did you get a chance to look into this last week?

@CarmenPopoviciu
Copy link
Contributor

Pete has a PR for it at #6511

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working pages Relating to Pages
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants