Skip to content

Hot reload not working on WSL #5155

Open
@Lekato98

Description

@Lekato98

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

Activity

a4amado

a4amado commented on Sep 13, 2023

@a4amado
Contributor

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

angelhdzmultimedia

angelhdzmultimedia commented on Sep 13, 2023

@angelhdzmultimedia

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

riley-git commented on Sep 14, 2023

@riley-git

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

angelhdzmultimedia commented on Sep 14, 2023

@angelhdzmultimedia

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

angelhdzmultimedia commented on Sep 16, 2023

@angelhdzmultimedia

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

Lekato98 commented on Sep 16, 2023

@Lekato98
Author
angelhdzmultimedia

angelhdzmultimedia commented on Sep 19, 2023

@angelhdzmultimedia
angelhdzmultimedia

angelhdzmultimedia commented on Sep 19, 2023

@angelhdzmultimedia
Yor-dan

Yor-dan commented on Sep 19, 2023

@Yor-dan

@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 😂

jakeg

jakeg commented on Nov 22, 2023

@jakeg
Contributor

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

AJR07 commented on May 31, 2024

@AJR07

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.

max-programming

max-programming commented on Mar 1, 2025

@max-programming

Hey but what is the solution if you want to keep it under the windows file system? I have a backend app that I want to run with WSL and it is nested inside a frontend app that I run in Windows normally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds investigateNeeds to be investigated to find the root cause

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @jakeg@Electroid@angelhdzmultimedia@Lekato98@riley-git

      Issue actions

        Hot reload not working on WSL · Issue #5155 · oven-sh/bun