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

🐛 BUG: wrangler dev does not work on Termux/Android

Open Resonious opened this issue 2 years ago • 1 comments

What version of Wrangler are you using?

2.0.27

What operating system are you using?

Android

Describe the Bug

I realize I may be a freak for developing on Android, but alas I do and I'm unable to perform the quick Workers example on the readme.

The npx wrangler dev index.js command does run "successfully", but it spam reloads and the server is inaccessible. SmartSelect_20220825-211751_Termux

Pretty much the same result whether or not I pass --local. A basic Express server runs fine on this device so I don't think there's anything wrong with my environment.

Resonious avatar Aug 25 '22 12:08 Resonious

Hey @Resonious, don't suppose you have any tips/guides for setting up an android to replicate this bug?

rozenmd avatar Sep 12 '22 14:09 rozenmd

@rozenmd Sorry for the slow follow-up! One popular Android terminal emulator is Termux.

On Termux, you can pkg install nodejs and npx wrangler generate test. Running npx wrangler dev on the fresh project will reproduce this issue.

Resonious avatar Oct 23 '22 12:10 Resonious

Invoking Miniflare directly appears to work fine, so I'm guessing there's something about the way Wrangler forks Miniflare that Android doesn't like.

Resonious avatar Oct 24 '22 00:10 Resonious

Quick update! I have some free time today so I'm looking into this. So far I've traced this back to the esbuild watcher. The watcher seems to be constantly reporting changes. If I remove the bundle from the React effect that restarts the server, it "works" as long as I toggle local mode or do something else to kick off the initial build/run.

I'm going to see if I can figure out whether this is actually an esbuild bug on Android or if there's some config we can pass to calm it down.

Resonious avatar Oct 28 '22 07:10 Resonious

This seems related but it's supposedly fixed already: https://github.com/evanw/esbuild/issues/1113

Resonious avatar Oct 28 '22 07:10 Resonious

Yeah okay sorry for the spam. I was able to reproduce this with just esbuild: esbuild --bundle --watch index.js.

I opened an issue on esbuild itself: https://github.com/evanw/esbuild/issues/2640 - once that's fixed, all we need to do is update the esbuild dependency in Wrangler.

Resonious avatar Oct 28 '22 08:10 Resonious

This problem seems to still exist in the latest release (2.4.4)

jiesou avatar Nov 24 '22 11:11 jiesou