-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Hot reload - needs debounce on file watch #2987
Comments
Sometimes Bun hot reloads faster than your text editor can save the files. I suspect that's the cause (the text editor truncated the file to 0, bun reloaded it, then it saved the rest, Bun reloaded again) |
Ok can confirm issue only happens with file upload via SSH. Should probably add a short couple of millisecond debounce on file watching so it only reloads once. If multiple files get updated you need to give it time to update all files, like a git pull etc. Could make it configurable, |
Also Iooks like the SSH file upload is appending to the file in chunks so over a certain size file 4KB it hot reloads a partial file. Just need some amount of debounce time either by default or configurable. Hot Reload is a really nice feature for keeping WebSockets/HTTP connections open and updating the app so would be nice to make it work well |
This error still exists and I don't think there's anything I can do to from the command line to make it work properly. I save my files and sometimes, half the time, I save it and it gives me the error |
I'm also running into this issue with I assume this is the same problem so I didn't create a new issue for it. |
Thank you @brw, the problem was completely mitigated from my environment using |
Same issue as @brw with I don't love going without swap files, but I save frequently enough and nvim crashes infrequently enough that it shouldn't be an issue in Bun-based projects. |
This was done in >= Bun v1.1.20 When multiple reloads are sent before the next one finishes, they're deduped. This fixes cases where bun would not be watching files that need to be watched in order to reload at the right time If you're still running into issues with this please leave a comment |
Hi @Jarred-Sumner, I'm using bun v1.1.29 (I also tried with v1.1.20), and with neovim the issue persist. I've confirm that this is not happening with vscodium for example. |
The issue is not resolved here either. |
I'm seeing this still on Linux (Arch) and bun 1.1.38. I have prettierd which autoformats my files on save. |
Hit the same issue with neovim for both |
What version of Bun is running?
0.6.2
What platform is your computer?
Linux 5.19.0-1025-aws aarch64 aarch64 (Ubuntu 22.04)
What steps can reproduce the bug?
While in Hot Reload mode, updating a module file via SSH gives error on reload. Looks like it successfully loads the updated file and continues running correctly, just displays an error:
SyntaxError: Import named 'a' not found in module '/home/ubuntu/bun/a.mjs'.
Now save new version of
a.mjs
What is the expected behavior?
No error
What do you see instead?
SyntaxError: Import named 'a' not found in module '/home/ubuntu/bun/a.mjs
Additional information
No response
The text was updated successfully, but these errors were encountered: