cloudflare / workers-sdk

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®
https://developers.cloudflare.com/workers/
Apache License 2.0
2.73k stars 724 forks source link

🐛 BUG: Wrangler dev stops responding after a custom build command runs #5440

Closed nneil closed 4 months ago

nneil commented 7 months ago

Which Cloudflare product(s) does this pertain to?

Pages, Wrangler core

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

wrangler 3.40.0

What version of Node are you using?

v20.11.1

What operating system and version are you using?

Windows 10

Describe the Bug

When I run wrangler it runs eleventy as expected. If I change one of the source files then wrangler runs eleventy, but then no longer responds to HTTP requests.

wrangler.toml

compatibility_date="2024-03-29"

[build]
command = "eleventy"

running wrangler

> wrangler pages dev _site
No functions. Shimming...
 ⛅️ wrangler 3.40.0
-------------------
Running custom build: eleventy
[11ty] Writing _site/index.html from ./src/index.md (liquid)
[11ty] Wrote 1 file in 0.16 seconds (v2.0.1)
⎔ Starting local server...
[wrangler:inf] Ready on http://127.0.0.1:8787
[wrangler:inf] GET / 200 OK (32ms)
[wrangler:inf] GET /favicon.ico 200 OK (13ms)
The file src\index.md changed, restarting build...
Running custom build: eleventy

11ty] Writing _site/index.html from ./src/index.md (liquid)
[11ty] Wrote 1 file in 0.14 seconds (v2.0.1)

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

nneil commented 7 months ago

I have found that running wrangler directly from Windows Terminal produces an assert error. I was previously running from within VScode. But I could not reproduce it to capture the error.

Here is a sample repo: https://github.com/nneil/cloudflare-wrangler-bug

nneil commented 7 months ago

Any progress on this. It's still a problem with "^3.45.0" and it's really slowing my development process. I've moved from eleventy to parcel in the meantime. Wrangler still stops responding after a rebuild. It does respond to the "b" and "x" keys though.

CarmenPopoviciu commented 7 months ago

Hi @nneil, thank you for reporting this issue.

Just to clarify, when you say you "run wrangler", are you referring to running the wrangler pages dev command?

I'm also seeing you are using a wrangler.toml config file with Pages. Please note that Pages does not support the build field in wrangler.toml, and therefore specifying it won't behave as expected. I suspect this is the reason you are seeing the weird behaviour.

The most straightforward way to make this work in Pages is to build your application to your [directory] of static assets, using your custom build command, then run wrangler pages dev [directory]. This will give you a more faithful emulation of production behavior.

Please let me know if that fixed the issue for you <3

nneil commented 7 months ago

Thanks for the response. That makes sense. I'm finding it easy to get mixed up between configuration for pages, functions, and workers.

I'm currently using parcel in one window and wrangler in another. That more or less works but I am not always seeing the automatic reloads that I would hope for. Is wrangler pages dev <dir> meant to watch the directory for changes? It's not clear to me from the documentation.

CarmenPopoviciu commented 5 months ago

Hi @nneil

My apologies for the late reply. The message got lost in the too many other GH notifications :(

wrangler pages dev is meant to watch for a couple of things:

To auto reload HTML pages when change is detected, you would need to use wrangler pages dev --live-reload. Unfortunately we have an open report that --live-reload is also broken atm, but am hoping we can fix soon.

Where exactly in the docs were you reading about the watch mode in pages dev. I can try to open a PR that clarifies things a little

CarmenPopoviciu commented 4 months ago

hi @nneil

we recently merged a bunch of changes that improved that pages dev watch mode. Can you pls give latest wrangler a go and see if you are still experiencing issues? 🙏 <3

nneil commented 4 months ago

Sadly the sudden abandonment of a way to send email from Cloudflare Pages Functions has caused me to stop working on my Cloudflare projects and go back to more traditional solutions.

CarmenPopoviciu commented 4 months ago

I'm sorry to hear that </3

the sudden abandonment of a way to send email from Cloudflare Pages Functions

are you referring to MailChannels whose partnership (free emails without an account from Workers/Functions) is ending? Resend is our recommended alternative to that, in case that helps your use case