nue icon indicating copy to clipboard operation
nue copied to clipboard

Vim "4913" file causes hotreload to fail

Open Korab-Doroci opened this issue 1 year ago • 19 comments

I reinstalled Nue with the latest version of bun. Tested it out with bun create nue@latest and I chose the hot reload test preset.

Everytime I change something in the source files, my terminal returns Removed .dist/dev/4913 Everytime, no matter what file I edit or delete and it does not hot reload. To force it to reload I have to delete the dist folder and restart the nue command in the terminal.

`✓ Initialize ./.dist/dev nue.js diffdom.js page-router.js app-router.js mount.js hotreload.js error.css favicon.ico

✓ Nue 0.1.7 • Bun 1.0.18 ✓ Serving site from ./.dist/dev ✓ Building site to: ./.dist/dev

✓ Processing styles 3 media.css content.css layout.css

✓ Generating pages 1 index.md

✓ Copying static files 1 hello.jpg

Time taken: 128ms

✓ http://localhost:8080/ ✓ Removed .dist/dev/4913 `

Extra details: Project was created in the downloads directory of the home directory. Bun was not installed with root. Issue recreated using different presets like the app skeleton and hot reload but also initializing a project myself. I'm on Debian sid. Nue v0.1.7. Bun v1.0.18. Node v18.19.0.

Korab-Doroci avatar Dec 20 '23 22:12 Korab-Doroci

Are you using Vim by any chance? Noticed that it creates a file called 4913. Likely relates to that.

tipiirai avatar Dec 21 '23 01:12 tipiirai

Trying to repeat this issue with Mac. Hotreload worked fine with a console command such as

echo '# Test 36' > test.md && touch 4913 && rm 4913

tipiirai avatar Dec 21 '23 01:12 tipiirai

Yes, I do use Vim. I tried changing editor and it worked perfectly, thanks for pointing it out!

Korab-Doroci avatar Dec 21 '23 13:12 Korab-Doroci

I re-opened this issue, since Vim still fails. Need to fix that somehow.

Thanks!

tipiirai avatar Dec 22 '23 04:12 tipiirai

It seems I'm noticing the same issue on my machine as well. But for clarification, hot reloading refers to being able to edit a file and have the site change without a reload being necessary correct?

Darth-Ness avatar Jan 08 '24 13:01 Darth-Ness

@Darth-Ness Any ideas on how I could repeat this issue? I tried different echo/touch combinations and MacVim without luck.

tipiirai avatar Jan 15 '24 11:01 tipiirai

Unfortunately no. Maybe it's just a Linux thing? But I did notice when trying to track the issue down, after editing a file with Vim, the XHR request originating from line 4 in hotreload.js wouldn't fire anymore Although on my machine it's actually line 65.

Darth-Ness avatar Jan 15 '24 11:01 Darth-Ness

@Darth-Ness can you try with the latest version (0.3.1) and see if it works? I pushed a potential fix. Thanks!

tipiirai avatar Jan 16 '24 11:01 tipiirai

Even after updating it seems your commit didn't take place, so I just edited the file myself. Even though bunx nuekit --version says I have 0.3.1 However, it seems that the problem is still here.

Darth-Ness avatar Jan 16 '24 12:01 Darth-Ness

Okay. Thanks. Need to try something else.

tipiirai avatar Jan 16 '24 20:01 tipiirai

Okay. Thanks. Need to try something else.

Do you think trying to ignore the 4913 file could work? I tired that on my local machine and then hotreload wouldn't work at all. I guess I have alot to learn about the codebase lol.

Darth-Ness avatar Jan 16 '24 20:01 Darth-Ness

It kind of works now. The only problem is that I have to save twice, once makes the change to 4913, and the second time the file im editing.

✓ Removed .dist/dev/style/4913
✓ Removed .dist/dev/style/global.css~

Korab-Doroci avatar Jan 16 '24 21:01 Korab-Doroci

Oh oh. The problem has gotten even weirder. I tried the method above, and at first it didn't work. However, when I realized a difference was I was using Neovim, I tried using just plain VIM (with the same config). After that, the method did work.

Darth-Ness avatar Jan 17 '24 00:01 Darth-Ness

WAIT! After running ls -a in the .dist/dev directory, I noticed that there was a file named .016 (is there a purpose for this file? It's empty.) deleting this file fixed Vim's behavior. All though Neovim isn't working still.

Darth-Ness avatar Jan 17 '24 00:01 Darth-Ness

Could it be, that it is a leftover from v0.1.6?

I think this code part has been changed according to the version: https://github.com/nuejs/nue/blob/994849888e42725d5649a048952eb71e15aec6d1/packages/nuekit/src/init.js#L21

nobkd avatar Jan 17 '24 01:01 nobkd

The files isn't on GitHub either. Maybe, because that line does read .016 on my machine. @tipiirai do you have any idea what this file is here for?

Darth-Ness avatar Jan 17 '24 01:01 Darth-Ness

That is indeed a leftover from v0.1.6. Nue adds this file to signal the version of the nue-specific files. If there is a new version all the files are replaced with newer ones. Maybe not perfect, but works.

tipiirai avatar Jan 18 '24 08:01 tipiirai

This might actually be a larger problem than just Vim. Placing a file that is in the IGNORE array defined here in the same directory with index.md breaks hot-reloading entirely.

Darth-Ness avatar Jan 21 '24 12:01 Darth-Ness

Can you check if this still happens with nuekit 1.0.0-beta.1? Thank you

nobkd avatar Aug 19 '24 05:08 nobkd