You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Content script is reloaded twice when the file is saved. #938
Hmm, not what I expected. It seems like VS Code is saving the file multiple times, and slow enough that my current debouncing logic isn't considering it a single save.
On my side, the only thing I could do is increase the delay, or replace the current logic with a real throttle. But I haven't seen anyone else with this error, so I'd like to figure out why it's happening to you first.
Do you have any extensions installed that would be causing this? Can you restart vscode and open it with extensions disabled to see if that's the problem?
Hmm, I was able to reproduce this. Sometimes I got multiple “changed” logs. It happens sometimes when saved(⌘+S) once every 3sec by feel. Doesn't seem to be caused by personal something tool, it occurs in both npm and pnpm with VSCode and TextEdit.app
Nah, if I look closely at…it's a bit different from his. He has [Changed: -> Reloaded:] x3, but I have multiple Changed: and Reloaded: is not shown after that. 🤷
Edit: He also gets multiple browser alerts, but I only get 1 So I couldn't reproduce.
@kazu-ux Okay, once you said that it does not reproduce in Notepad, is it 100% ? If so, we can say the problem isn't with chokidar. Because in the video you posted with the code --disable-extensions, the problem isn't happening at “Hello content. 2” and the timing is causing the problem at “Hello content. 3”. So the problem may in fact occur with Notepad if you try it many times.
@kazu-ux Thanks for many tried. So…it may as I thought, be a VSCode issue or that with the VSCode's integrated terminal. We can only suspect VSCode settings, but what happens if you try set .output dir to the Files: Watcher Exclude and disable to TypeScript > TsServer > Experimental: Use Vs Code Watcher with workspace settings?
You could add the below code to .vscode/settings.json, or set up in the GUI.
Activity
aklinker1 commentedon Aug 29, 2024
Can't reproduce:
Video
output.mp4
But I think I can guess what the problem is. Can you apply this patch and share the logs?
kazu-ux commentedon Aug 30, 2024
I applied the patch.
wxt-video04.mp4
I noticed that the Content script works correctly when I update the code using Notepad.
wxt-video03.mp4
aklinker1 commentedon Aug 30, 2024
Hmm, not what I expected. It seems like VS Code is saving the file multiple times, and slow enough that my current debouncing logic isn't considering it a single save.
On my side, the only thing I could do is increase the delay, or replace the current logic with a real throttle. But I haven't seen anyone else with this error, so I'd like to figure out why it's happening to you first.
Do you have any extensions installed that would be causing this? Can you restart vscode and open it with extensions disabled to see if that's the problem?
kazu-ux commentedon Aug 30, 2024
I tried creating a new profile and disabling extensions, but the issue still persists.
wxt-video05.Clipchamp.mp4
1natsu172 commentedon Aug 30, 2024
Hmm,

I was able to reproduce this.Sometimes I got multiple “changed” logs. It happens sometimes when saved(⌘+S) once every 3sec by feel.Doesn't seem to be caused by personal something tool, it occurs in bothnpmandpnpmwithVSCodeandTextEdit.app1natsu172 commentedon Aug 30, 2024
Nah, if I look closely at…it's a bit different from his. He has [
Changed:->Reloaded:] x3, but I have multipleChanged:andReloaded:is not shown after that. 🤷Edit: He also gets multiple browser alerts, but I only get 1 So I couldn't reproduce.
1natsu172 commentedon Aug 31, 2024
@kazu-ux The difference between our environment and yours is that Windows/MacOS and you are using different disk drives
C:&D:(I noticed it).And I found the Windows drive issue in Chokidar paulmillr/chokidar#665 - does the problem continue when you run WXT on the
C:drive?kazu-ux commentedon Sep 7, 2024
The same issue occurred on the C drive.
1natsu172 commentedon Sep 7, 2024
@kazu-ux Okay, once you said that it does not reproduce in Notepad, is it 100% ? If so, we can say the problem isn't with chokidar. Because in the video you posted with the
code --disable-extensions, the problem isn't happening at “Hello content. 2” and the timing is causing the problem at “Hello content. 3”. So the problem may in fact occur with Notepad if you try it many times.kazu-ux commentedon Sep 7, 2024
Yes, I edited the code 50 times in Notepad, but no issues occurred.
1natsu172 commentedon Sep 7, 2024
@kazu-ux Thanks for many tried. So…it may as I thought, be a VSCode issue or that with the VSCode's integrated terminal. We can only suspect VSCode settings, but what happens if you try set
.outputdir to theFiles: Watcher Excludeand disable toTypeScript > TsServer > Experimental: Use Vs Code Watcherwith workspace settings?You could add the below code to
.vscode/settings.json, or set up in the GUI.{ "files.watcherExclude": { "**/.output/**": true }, "typescript.tsserver.experimental.useVsCodeWatcher": false }I can only think that something primitive in VSCode is the cause.
kazu-ux commentedon Sep 9, 2024
I changed settings. but the issue still persists.
I noticed that it works properly when I edit the popup code.
wxt-video06.Clipchamp.mp4
6 remaining items
1natsu172 commentedon Sep 12, 2024
Maybe we should follow the chokidar v4 and vite movement and only ready the stable passing watcher option in place until then.
aklinker1 commentedon Sep 12, 2024
Yeah, I'm good with that. For now, let's just add debouncing
1natsu172 commentedon Sep 12, 2024
Let's do so. I can work on it, but do you have any particulars about the debounce library?
aklinker1 commentedon Sep 12, 2024
@1natsu172 thanks!
I prefer unjs packages: https://unjs.io/packages/perfect-debounce
But if there's already another as a sub dependency, we can use that one too
1natsu172 commentedon Sep 14, 2024
@kazu-ux We are working on PR for this issue. For reference, we would like to know how many seconds the reload actually takes, so please help us out.
The following patch will give you the seconds for reloading.
pnd280 commentedon Sep 14, 2024
Highlighted regions are double reloads
btw, disable
trailingseems to fix the issue 21446b1kazu-ux commentedon Sep 14, 2024
I patched the code.
1natsu172 commentedon Sep 14, 2024
@kazu-ux @pnd280 Thanks both. Hmm It is taking longer than thought. About 800ms max.... I found it helpful. I'll keep you posted on any progress!
aklinker1 commentedon Sep 18, 2024
Chokidor v4 just got dropped: https://github.com/paulmillr/chokidar/releases/tag/4.0.0
But we'll probably have to wait for Vite 6 before using it
kazu-ux commentedon Sep 24, 2024
I updated wxt to 0.19.10, the issue was resolved. Thank you!
1natsu172 commentedon Sep 24, 2024
@kazu-ux Oh sorry, I forgot to tell you that it's released. Glad to hear it has been resolved! (cc: @pnd280).
Can adjust it by environment variable.
aklinker1 commentedon Sep 26, 2024
Gonna go ahead and close this as completed!