workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

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

Open nneil opened this issue 1 year ago • 5 comments

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 avatar Mar 29 '24 12:03 nneil

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 avatar Mar 29 '24 12:03 nneil

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.

nneil avatar Apr 04 '24 09:04 nneil

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

CarmenPopoviciu avatar Apr 24 '24 14:04 CarmenPopoviciu

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.

nneil avatar Apr 25 '24 17:04 nneil

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:

  • changes in the /functions directory - if you are using Functions
  • changes in _worker.js - if you are in Advanced Mode
  • changes in any dependencies imported in either your Functions or your _worker.js (this is currently broken atm, but will be fixed by https://github.com/cloudflare/workers-sdk/pull/6022 and https://github.com/cloudflare/workers-sdk/pull/6022)
  • changes in _routes.json

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 avatar Jun 26 '24 12:06 CarmenPopoviciu

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

CarmenPopoviciu avatar Jul 05 '24 07:07 CarmenPopoviciu

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.

nneil avatar Jul 05 '24 08:07 nneil

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

CarmenPopoviciu avatar Jul 05 '24 10:07 CarmenPopoviciu