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

[Linux] Dev mode seems broken on 1.5 #202

Open
gregod opened this issue Jul 28, 2021 · 6 comments · May be fixed by #205
Open

[Linux] Dev mode seems broken on 1.5 #202

gregod opened this issue Jul 28, 2021 · 6 comments · May be fixed by #205
Labels
bug Something isn't working

Comments

@gregod
Copy link
Contributor

gregod commented Jul 28, 2021

Hi,
from 1.5 onwards the reload in the dev auto reload mode seems to be broken for elder routes on my system.
If this is a system configuration (Linux, Node 16.5) issue i can provide some more logs but im hoping this can be verified independently on your end.
I believe this is an error in regenerating the HTML but am not familiar enough with the rollup/esbuild plugins to debug it myself.

This is all on a fresh elder template retrieved via npx degit Elderjs/template elder-demo which uses a >=1.5 elderjs version.

When i start npm run dev and modify a component in the "components" subfolder (Clock.svelte), the the change is picked up by the watcher, is compiled and both JS, and the HTML is updated as expected.
However, if i modify a route file (Home.svelte, changing the h1 tag) the change is picked up by the watcher, the js is compiled, but the html is not updated! The browser does not reload, and if i manually do, the css and js is broken since the old html points to the wrong asset hashes.

On 1.4.16 this still works fine, on 1.5 and following it does not.
This also affects esbuild.

@nickreese
Copy link
Contributor

Not experiencing these issues and working in Elder across multiple teams daily.

There was an issue in earlier versions of 1.5 but current doesn’t have any besides a css import/caching issue in dev mode which I just identified today.

Can you try deleting your package.lock and making sure you are on latest?

@nickreese
Copy link
Contributor

I’d love more logs on this if you have them. Happy to dig in.

@gregod
Copy link
Contributor Author

gregod commented Jul 29, 2021

Since its works on your end i did some more digging. So the issue is that the server is not restarted after a change of the route files.
I believe there is an issue with the chokidar package used to detect file changes on (my) linux. I guess you are using macosx, which this plugin is natively designed to support?

I did some "console.log" debugging on the change handler in

function handleChange(watchedPath) {
const parsed = path.parse(watchedPath);
if (parsed.ext !== '.svelte') {
// prevents double reload as the compiled svelte templates are output
startOrRestartServer();
}
}
and it does not pick up all changes.
Most importantly it misses the changes in the "ELDER/compiled/routes" folder which would contain the changes in the home route. Maybe since it has to fall back to polling on linux it gets overwhelmed by the many changes?

What hides this somewhat, and hides this issue on the pre v1.5 versions is that the important "startOrRestartServer()" is also called by the "writeBundle()" in the same file

if (startDevServer && type === 'client') {
startWatcher();
startOrRestartServer();
}

This is also called on all changes (?) and triggers a restart if the type == "client". Hence the restart working on my system if a client component is changed. In the pre 1.5 versions this type check is missing,
writeBundle() {
if (type === 'ssr') {
// copy over assets from the ssr folder to the client folder
const ssrAssets = path.resolve(elderConfig.rootDir, `.${sep}___ELDER___${sep}compiled${sep}assets`);
const clientAssets = path.resolve(elderConfig.$$internal.distElder, `.${sep}assets${sep}`);
fs.ensureDirSync(clientAssets);
const open = fs.readdirSync(ssrAssets);
if (open.length > 0) {
open.forEach((name) => {
fs.copyFileSync(path.join(ssrAssets, name), path.join(clientAssets, name));
});
}
}
startServerAndWatcher();
and the server is restarted after every "writeBundle()" build. This then picks up the changes in the route.

There is a chance that this is just my linux system maybe someone else on linux could try to reproduce?.

@nickreese
Copy link
Contributor

I believe there is an issue with the chokidar package used to detect file changes on (my) linux. I guess you are using macosx, which this plugin is natively designed to support?

Yep, Mac OS, though one team member is on Linux Arch and he has mentioned having to restart to get changes, IIRC. I will ask him more about his experience to see if he can recreate it.

I know @lukeed coached me through an issue with polling and chokidar so I will ping him as well.

@nickreese
Copy link
Contributor

Just confirmed with a team member, he has issues on and off with changes not being detected in Arch Linux.

@nickreese nickreese changed the title Dev mode seems broken on 1.5 [Linux] Dev mode seems broken on 1.5 Jul 30, 2021
@denkan
Copy link

denkan commented Sep 6, 2021

FYI: This also happens on Windows 10.
Tested on a clean npx degit Elderjs/template svelte-elderjs2 install.

@eight04 eight04 added the bug Something isn't working label Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants