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

Hot reload not working on WSL #5155

Open
Lekato98 opened this issue Sep 12, 2023 · 11 comments
Open

Hot reload not working on WSL #5155

Lekato98 opened this issue Sep 12, 2023 · 11 comments
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause

Comments

@Lekato98
Copy link

What version of Bun is running?

1.0.1+31aec4ebe325982fc0ef27498984b0ad9969162b

What platform is your computer?

WSL Ubuntu 20.04 Over Microsoft Windows NT 10.0.22621.0 x64

What steps can reproduce the bug?

  1. install express & types bun install express bun install -d @type/express
  2. Copy the below snippet code to index.ts
import express from 'express';
const app = express();

app.get('*', (req, res) => res.json({healthCheck: 'OKZ'}))

app.listen(8080, () => console.info('Server listening to 8080'))
  1. run the app using hot or watch [bun --watch index.ts or bun --hot index.ts]
  2. Hit localhost:8080 and you should receive OKZ as a response
  3. While the server is running, replace OKZ with OKAYZ
  4. Hit the endpoint back and you will receive OKZ again

What is the expected behavior?

While the server is running using --watch or --hot it should perform hot reload for the application, so instead of receiving OKZ in step #6 instead it should return OKAYZ

What do you see instead?

While the server is running using --watch or --hot I keep receiving the initial server build

Additional information

There is an open thread on discord, link

@Lekato98 Lekato98 added the bug Something isn't working label Sep 12, 2023
@a4addel
Copy link
Contributor

a4addel commented Sep 13, 2023

Same error here, I faced the same error with WSL, I installed Ubuntu and still face the same error.

@angelhdzmultimedia
Copy link

angelhdzmultimedia commented Sep 13, 2023

Same issue here since yesterday. I thought I was doing something wrong. Ubuntu WSL.
Also having other issues with Hono and Elysia and the request body... SyntaxError: Unexpected end of JSON input... also reported.

Edit: Solved this in a later reply. Also solved the Elysia/Hono issue, I was using a GET request of course the body is not valid!

@riley-git
Copy link

If your project is located in the windows file system and you're accessing them through /mnt with WSL, hot reload will not work. See here.

Moving my project and working within Linux environment allowed me to use --hot.

@angelhdzmultimedia
Copy link

angelhdzmultimedia commented Sep 14, 2023

If your project is located in the windows file system and you're accessing them through /mnt with WSL, hot reload will not work. See here.

Moving my project and working within Linux environment allowed me to use --hot.

Thank you! Solved for me.

Anyone knows how to open a VSCode window on Windows but using the linux file system with WSL?
I managed to move my bun project from windows file system to linux file system and now --watch/--hot work,
but I lose all my VSCode extensions because it's using a linux version of VSCode...

Edit: Nevermind. All extensions are installed. What I lost was the shortcuts to them on the left sidebar.

Edit 2: To anyone that needs this tip, to open VSCode in the linux file system with WSL:
Install these extensions:
image

And then:
image

Code_41bjxjKyP5.mp4

Edit 3: Got my extensions working. I had to browse the extensions I use, and then I get a hint besides the extensions name "install in WSL". Some extensions need this.

@angelhdzmultimedia
Copy link

Thanks, feel free to close the ticket since I've shared my feedback and there is no further action required. Regards, Hamza

On Thu, Sep 14, 2023 at 11:21 PM Angel Hernandez @.> wrote: If your project is located in the windows file system and you're accessing them through /mnt with WSL, hot reload will not work. See here <#4335 (comment)>. Moving my project and working within Linux environment allowed me to use --hot. Thank you! Solved for me. Anyone knows how to open a VSCode window on Windows but using the linux file system with WSL? I managed to move my bun project from windows file system to linux file system and now --watch/--hot work, but I lose all my VSCode extensions because it's using a linux version of VSCode... — Reply to this email directly, view it on GitHub <#5155 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKE3OQFBA4ZJ5Q5ZGGNVRMDX2NRLDANCNFSM6AAAAAA4VNI5IM . You are receiving this because you authored the thread.Message ID: @.>

I'm not the Issue's author. Thank you.

@Lekato98
Copy link
Author

Lekato98 commented Sep 16, 2023 via email

@angelhdzmultimedia
Copy link

angelhdzmultimedia commented Sep 19, 2023 via email

@angelhdzmultimedia
Copy link

angelhdzmultimedia commented Sep 19, 2023 via email

@Yor-dan
Copy link

Yor-dan commented Sep 19, 2023

@yordan Trivada Bian didn't find your reply in the bun hot reload Issue page. I just learned we can reply via email!

Anyway, as far as I know, and I can be wrong of course, the hot reloading on the browser needs communication via sockets, and that's how Vite does it.
The browser needs to connect to the server and know when the code changed and was rebuilt to add the modified changes to the DOM.

It happened to me with a library that is Vite Node, I was so used to Vite's hot reload in the browser, that when I tried a backend project, I expected the browser to also reload hahaha. 😂

Maybe Bun's hot reload injects some code in the served HTML pages to achieve this, I will read about it now.


From: Yordan Trivada Bian @.>
Sent: Monday, September 18, 2023 2:17 PM
To: oven-sh/bun @.
>
Cc: Angel Hernandez @.>; Comment @.>
Subject: Re: [oven-sh/bun] Hot reload not working on WSL (Issue #5155)

If your project is located in the windows file system and you're accessing them through /mnt with WSL, hot reload will not work. See here#4335 (comment).

Moving my project and working within Linux environment allowed me to use --hot.

thanks this solve the issue. Now I could see my file reload in the terminal, but when I setup an http server my browser (chrome) didn't reload automaticaly (I have to refresh to see the changes). Do you have any clue to solve this?


Reply to this email directly, view it on GitHub#5155 (comment), or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACNYB3MLVLJ3TEKMYRJEAZLX3CF3FANCNFSM6AAAAAA4VNI5IM.
You are receiving this because you commented.Message ID: @.***>

thank you for your reply, I was confused by the docs where they show the browser reload side by side comparison with nodemon in Watch Mode > --hot mode section.

exactly like what you did mention, I am currently learning svelte which also has hot reload, and I am just so used to it that I even expect backed code to reflect hot reload in the browser without send a new request 😂

@Electroid Electroid added the needs investigate Needs to be investigated to find the root cause label Oct 27, 2023
@jakeg
Copy link
Contributor

jakeg commented Nov 22, 2023

Can confirm both --hot and --watch don't work in WSL on files from Windows' file system. It never reloads. It would be good if Bun at least showed a message to say it doesn't work.

@AJR07
Copy link

AJR07 commented May 31, 2024

Just want to resurface this issue of not being able to --hot and --watch on WSL, would be great if a fix or a notice can be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause
Projects
None yet
Development

No branches or pull requests

8 participants