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

--watch rebuilds code constantly (Android) #2640

Closed
Resonious opened this issue Oct 28, 2022 · 3 comments
Closed

--watch rebuilds code constantly (Android) #2640

Resonious opened this issue Oct 28, 2022 · 3 comments

Comments

@Resonious
Copy link

Hello. This is basically the same as #1113, but I'm only seeing it on Android/Termux. --watch mode works fine for me on Linux and Windows.

On Android (aarch64, kernel 5.4.147), if I run esbuild --bundle index.js --watch, it rebuilds the file nonstop. Happens for a single one-line file in an otherwise empty directory, and also for a large/complex app.

Let me know if there's anything I can provide to assist in troubleshooting. I might dig around the code myself if I can find time.

@evanw
Copy link
Owner

evanw commented Oct 28, 2022

The reason why rebuilds are happening should already be printed to the terminal. What does the terminal output say?

@Resonious
Copy link
Author

Ah yes I missed that. It says

[watch] build started (change: "../../../../..")

That resolves to /data/data which I do not have permission to access.

@evanw
Copy link
Owner

evanw commented Oct 29, 2022

Thanks. I think I know what's happening then. Android is unusual in that it has an inaccessible directory in the path to the root, which esbuild was not originally built to handle. To handle cases like this, the file system layer in esbuild has a hack where it treats inaccessible directories as empty.

However, esbuild's watch implementation currently triggers a rebuild if a directory previously encountered an error but the directory now exists. The assumption is that the previous error was caused by the directory not existing. Although that's usually the case, it's not the case here. Instead the error is that the directory previously existed but was inaccessible. This causes esbuild's watch implementation to rebuild continuously.

I can reproduce the issue myself so I should be able to fix this.

@evanw evanw closed this as completed in 97d6dba Oct 29, 2022
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

No branches or pull requests

2 participants