-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[Bug]: Live Reload not working. #1601
Comments
Check that the component is making it onto your page. If it's not, the first thing to check is what the value of NODE_ENV is when you run. If it's not "development", set it before you start the dev command. |
The component is on the page. I just double-checked the NODE_ENV by adding |
I still have not found a solution other than it the hot-reloading it working on my Linux machine but refuses to work on Windows. |
I'm also using Windows and I realized hot-reloads only work when I make changes inside the app directory of my Remix project. |
Same issue on MacOS. Nothing makes it work for me, even if i remove the I have reproduced the issue on I am using Its dropped the Remix DX from a 10/10 down to a 1/10. I've had to put my project on hold until this is fixed. :( All my components are inside the app directory |
Interesting observation. I was struggling with this and your point made me realize I currently have all my components in a As a possible feature, could we provide paths to whatever is watching the filesystem for hot reload? |
In my case I have all my components inside the |
I hit the same problems, then realised that WSL was sat in the middle. Live Reload started working perfectly once I moved my working directory to the Linux filesystem. https://docs.microsoft.com/en-us/windows/wsl/setup/environment#file-storage |
same problem here on Windows and |
It doesn't seem to work on my end, even though I have project files in
|
Thx. FIY everybody, if you move to Remix Stack (Blues) there is no issue with hot reloading in WSL2. It is using pm2 server internally for that, AFAIK. That's what I did. |
Hot reload doesn't work for me on I dug a little deeper and found the root cause here: microsoft/WSL#4739 This issue comes up across many tools, and the workaround is often to switch to polling.
Maybe remix should also offer a polling option? |
I don't mean to +1, but I'm also getting the issue on mac, with a fresh vercel/ts boilerplate. |
Same issue with me |
They had started removing Re-add the cross-env and it should work. |
@kiliman It doesn't work with or without manually setting |
Any known fixes? Running remix on WSL Ubuntu 20.04 |
export const LiveReload =
process.env.NODE_ENV !== "development"
? () => null
: function LiveReload({
port = Number(process.env.REMIX_DEV_SERVER_WS_PORT || 8002),
}: {
port?: number;
}) {
let setupLiveReload = ((port: number) => {
let protocol = location.protocol === "https:" ? "wss:" : "ws:";
let host = location.hostname;
let socketPath = `${protocol}//${host}:${port}/socket`;
let ws = new WebSocket(socketPath);
ws.onmessage = (message) => {
let event = JSON.parse(message.data);
if (event.type === "LOG") {
console.log(event.message);
}
if (event.type === "RELOAD") {
console.log("💿 Reloading window ...");
window.location.reload();
}
};
ws.onerror = (error) => {
console.log("Remix dev asset server web socket error:");
console.error(error);
};
}).toString();
return (
<script
suppressHydrationWarning
dangerouslySetInnerHTML={{
__html: `(${setupLiveReload})(${JSON.stringify(port)})`,
}}
/>
);
}; |
Had the same issue. Fixed by changing module.exports = {
ignoredRouteFiles: [".*"],
}; to: module.exports = {
cacheDirectory: "./node_modules/.cache/remix",
ignoredRouteFiles: [".*", "**/*.css", "**/*.test.{js,jsx,ts,tsx}"],
}; |
@nilobarp That's already in my |
I believe there was a bug in the dev tool in that it wasn't passing the |
@mikeybinnswebdesign wish it was a prank. I tried everything mentioned in this thread, the only thing that worked was the change in This is too much magic for my brain. |
LiveReload does not work for me, I copied the code that @kiliman shared and added more console logs. The frontend never seems to connect to the WS server and is just constantly pending. No Any suggestions? |
this helped!!! thanks so much :D |
If anyone tried everything that was suggested here and it still didn't work, I just restarted my MacBook and it's working now, seriously. |
The official remix tutorial runs straight into this problem. Not a good first experience with the framework |
What's the latest here? |
I had previously removed both |
I fix this by adding the /** @type {import('@remix-run/dev').AppConfig} */
export default {
ignoredRouteFiles: ["**/.*"],
watchPaths: ["./components"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// publicPath: "/build/",
// serverBuildPath: "build/index.js",
}; |
Reminder: you can use Vite now, which should improve this 🥳 https://remix.run/docs/en/main/future/vite#migrating |
Guess I should've actually read the docs first... fixed everything by changing my root.tsx from this: export default () => { To this: export default function Root() { I have no idea if this is a common limitation across frameworks, but the docs clearly state not to do what I was doing: https://remix.run/docs/en/main/discussion/hot-module-replacement. |
Good to know. |
Good to know! |
I was having the same issue with the blues stack, I started with the template that had LiveReload after Scripts. I changed the order now where LiveReload comes first, and now it is fixed. This is important if you are using vitest. From root.tsx:
|
This is the most basic feature a frontend dev framework should have; it's not working in Nov/2023 so I'll report to my team Remix is not worth considering yet 😇 |
It is working, but we have to improve the documentation because it'd work properly if you keep your code inside the |
My structure is as follows:
Does this mean I need to move Do I need to use named function for everything? |
There seem to be multiple different issues people are running into. Named exportsNamed exports are required for HMR. Note that this is a limitation of React Fast Refresh, not Remix. Thus the same limitation is present in Vite and Next. Code outside of
|
@alisnino are you facing a different issue than the ones I mentioned? |
Hey, @pcattori, first, I'd like to thank you for your amazing work integrating Vite. Here's an issue that I opened related to the Vite live reload: #7853 (there's a repo where you can reproduce it), and tbh it makes the DX really bad. Not sure how complex it is, but happy to take a look at the weekend if you could give me some pointers... |
@rodolphoasb let's keep the discussion for that on your issue since this issue is focused on the current (non-Vite) compiler/dev server |
Can anyone recommend a workaround for naming functions? Using arrow functions would have quite a few downsides |
It is here. |
@adaboese you can use |
Hey @pcattori, Even in the named exported functions from a package outside the app directory as below:
I am observing the HMR is not working when I make a change inside the Home package (I got it under ================ And the moment I change the route file as below, HMR starts working.
|
@dharmendra94 does this work in Vite? I'm wondering if this is just a limitation of the |
Hey, @pcattori, I have tried Vite, and the issue no longer exists. Now I am curious, when will |
I think |
I haven't tried it yet, but you might try adding |
https://twitter.com/markdalgleish/status/1736240852308251053 |
Which Remix packages are impacted?
remix
(Remix core)@remix-run/react
@remix-run/serve
What version of Remix are you using?
1.1.3
What version of Node are you using? Minimum supported version is 14.
14.17.4
Steps to Reproduce
Every step along the way I have to restart the dev server to see the changes in the web. For example I added
and the console still shows that it reloaded but still shows test2 (the value from when the dev server started)
Navigated to http://10.202.57.104:3000/posts
index.tsx:18 test2
posts:23 💿 File changed: app\routes\posts\index.tsx
posts:23 💿 Rebuilding...
posts:23 💿 Rebuilt in 201ms
posts:26 💿 Reloading window ...
Navigated to http://10.202.57.104:3000/posts
index.tsx:18 test2
I'm on Windows using Chrome(97.0.4692.71) and Edge(Version 97.0.1072.62), both failed
Expected Behavior
the hot reload should show the changes without having to restart
Actual Behavior
I have to stop the dev server and restart to see any changes
The text was updated successfully, but these errors were encountered: