fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Fresh dies with "transport was disconnected" on hmr in firefox

Open MonstraG opened this issue 2 months ago • 22 comments

Steps:

  1. install deno via curl -fsSL https://deno.land/install.sh | sh to make sure you get last (my distro has older version)
  2. deno clean
  3. deno run -Ar jsr:@fresh/init
  4. enter twice to not install tailwind or vscode stuff
  5. set "nodeModulesDir": "manual" in deno.json, otherwise it might not even run due to error 26 (I think it's https://github.com/denoland/deno/issues/30424)
  6. deno i --allow-scripts (I don't know if I actually need to allow them but to make sure)
  7. deno task dev
  8. open the page in firefox (http://localhost:5173/) (important!)
  9. open assets/styles.css with editor like kate and press Ctrl+S without modifying anything.

server dies with:

GET http://localhost:5173/
Shared value hello
8:44:12 AM [vite] vite.config.ts changed, restarting server...
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
8:44:12 AM [vite] (client) page reload client.ts
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry
8:44:12 AM [vite] (client) hmr update /assets/styles.css
8:44:12 AM [vite] (client) hmr update /@id/fresh-island::Counter.tsx
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry
8:44:12 AM [vite] (client) hmr update /components/Button.tsx
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry
8:44:12 AM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
8:44:12 AM [vite] (ssr) Error when evaluating SSR module fresh:server_entry: transport was disconnected, cannot call "fetchModule"
      at reviveInvokeError (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:473:14)
      at Object.invoke (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:547:11)
      at eventLoopTick (ext:core/01_core.js:179:7)
      at async SSRCompatModuleRunner.getModuleInformation (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1053:7)
      at async request (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1070:83)
      at async eval (fresh-route::__app:8:31)
      at async ESModulesEvaluator.runInlinedModule (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:906:3)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1113:59)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18607:22)
      at async SSRCompatModuleRunner.cachedRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1031:73)
      at async eval (fresh:server-snapshot:11:31)
      at async ESModulesEvaluator.runInlinedModule (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:906:3)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1113:59)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18607:22)
      at async SSRCompatModuleRunner.cachedRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1031:73)
      at async eval (fresh:server_entry:7:31)
      at async ESModulesEvaluator.runInlinedModule (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:906:3)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1113:59)
      at async SSRCompatModuleRunner.directRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18607:22)
      at async SSRCompatModuleRunner.cachedRequest (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1031:73)
      at async SSRCompatModuleRunner.import (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:992:10)
      at async instantiateModule (/home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18580:10)
      at async https://jsr.io/@fresh/plugin-vite/1.0.4/src/plugins/dev_server.ts:72:23
error: Uncaught (in promise) Error: transport was disconnected, cannot call "fetchModule"
    at reviveInvokeError (file:///home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:473:14)
    at Object.invoke (file:///home/arsga/Downloads/fresh-project-3/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:547:11)
    at eventLoopTick (ext:core/01_core.js:179:7)
    ...

Versions:

deno 2.5.3
fresh and all dependencies - whatever would `deno i` give in this template at the time of writing:
fresh itself: 2.1.1
vite: 7.1.9
firefox: 143.0.3
os: EndeavorOS
kernel: 6.16.8-arch3-1 (64-bit)

I'm gonna again stress that you have to open the page in the browser.

MonstraG avatar Oct 04 '25 06:10 MonstraG

https://github.com/user-attachments/assets/eb1ce5fe-6753-47c2-9d4e-bc5f6ffdd58c

MonstraG avatar Oct 04 '25 07:10 MonstraG

It also reproduces in chrome, but you need to ctrl+s like 6 times on average. Version 141.0.7390.54 (Official Build) (64-bit)

MonstraG avatar Oct 04 '25 07:10 MonstraG

I followed your steps and cannot reproduce this problem on my machine (macOS 15.7.1 aarch64). The HMR works fine and produces this output on the Vite dev server console:

10:37:38 [vite] (client) hmr update /assets/styles.css
GET http://127.0.0.1:5173/
Shared value hello

I noticed this error in your report:

cannot call "fetchModule"

This fetchModule is part of Vite. This part may fail in case of problems with CommonJS (which Fresh has to treat differently) or it seems with paths. At least this is what I can guesswork from looking through a bit code and commits, see e.g. here -> https://github.com/denoland/fresh/pull/3204

Since Fresh works perfectly fine on most other environments (CI tests Windows/macOS/Ubuntu Linux), can you please tell us more about your OS and its filesystem and network setup? Is there anything special about EndeavorOS?


For anyone reading, here are some general troubleshooting tips to try out. Those likely will not help in this case, but they also do no harm:

Clean the global Deno cache with (was already done in this case):

deno clean

Force reinstall everything bypassing all caches, node_modules folder, deno.lock (can help sometimes):

rm -fR deno.lock node_modules
deno install -r --allow-scripts

See also the troubleshooting guide for other common issues and solutions.

fry69 avatar Oct 04 '25 08:10 fry69

I did

deno clean
rm -fR deno.lock node_modules
deno install -r --allow-scripts

did not help me.

EndeavorOS is just Arch with a Calamares installer and KDE by default.

Here is about this system blurb, if useful to anyone:

Operating System: EndeavourOS 
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2
Kernel Version: 6.16.10-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 7600X 6-Core Processor
Memory: 64 GiB of RAM (61,9 GiB usable)
Graphics Processor 1: AMD Radeon RX 9070
Graphics Processor 2: AMD Radeon Graphics
Manufacturer: ASUS

The filesystem is ext4, the default.

Here is the network interfaces blurb:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether bc:fc:e7:1c:85:74 brd ff:ff:ff:ff:ff:ff
    altname enp10s0
    altname enxbcfce71c8574
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 60:ff:9e:3c:c3:42 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.132/24 brd 192.168.10.255 scope global dynamic noprefixroute wlan0
       valid_lft 78497sec preferred_lft 78497sec

I don't think I did anything special to my network setup, is there anything specific I can show you?

MonstraG avatar Oct 04 '25 09:10 MonstraG

FYI: Searching for the other part of your reported error (transport was disconnected) in context of Vite reveals a few open issues for Astro and Svelte, with reports of that sporadically happening, but nothing conclusive or even an obvious fix.

Also, even with hammering Ctrl+S and triggering HMR, I cannot reproduce this problem on my system:

11:24:40 [vite] (client) hmr update /assets/styles.css (x31)
GET http://127.0.0.1:5173/
Shared value hello

I use Firefox stable and have set nodeModulesDir to manual, as instructed.

fry69 avatar Oct 04 '25 09:10 fry69

FYI, here is a possible fix for this race condition, analysis in the PR: #3519

fry69 avatar Oct 04 '25 12:10 fry69

FYI, here is a possible fix for this race condition, analysis in the PR: #3519

I've added vendor: true to deno.json, and manually applied the fix from the PR. On save, it just died in a different place:

Error: transport was disconnected, cannot call "fetchModule"
    at reviveInvokeError (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:473:14)
    at Object.invoke (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:547:11)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async SSRCompatModuleRunner.getModuleInformation (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1053:7)
    at async request (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1070:83)
    at async eval (fresh-route::_index:8:31)
    at async ESModulesEvaluator.runInlinedModule (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:906:3)
    at async SSRCompatModuleRunner.directRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1113:59)
    at async SSRCompatModuleRunner.directRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18607:22)
    at async SSRCompatModuleRunner.cachedRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1031:73)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/fs_routes.ts:14:241)
    at async normalized (deno::0::https://jsr.io/@fresh/core/2.1.1/src/fs_routes.ts:14:88)
    at async normalized (deno::0::https://jsr.io/@fresh/core/2.1.1/src/commands.ts:21:1606)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/commands.ts:21:3255)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async eval (/home/arsga/Documents/code/WebstormProjects/fresh-project/main.ts:6:144)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async freshServeStaticFiles (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/static_files.ts:27:14)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async segmentMiddleware (deno::0::https://jsr.io/@fresh/core/2.1.1/src/segments.ts:13:1289)
    at async fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:686)
    at async runMiddlewares (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:55)
    at async Object.eval [as fetch] (deno::0::https://jsr.io/@fresh/core/2.1.1/src/app.ts:67:836)
    at async https://jsr.io/@fresh/plugin-vite/1.0.4/src/plugins/dev_server.ts:76:26 {
  runnerError: Error: RunnerError
    at reviveInvokeError (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:474:64)
    at Object.invoke (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:547:11)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async SSRCompatModuleRunner.getModuleInformation (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1053:7)
    at async request (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1070:83)
    at async eval (fresh-route::_index:8:31)
    at async ESModulesEvaluator.runInlinedModule (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:906:3)
    at async SSRCompatModuleRunner.directRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1113:59)
    at async SSRCompatModuleRunner.directRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:18607:22)
    at async SSRCompatModuleRunner.cachedRequest (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/module-runner.js:1031:73)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/fs_routes.ts:14:241)
    at async normalized (deno::0::https://jsr.io/@fresh/core/2.1.1/src/fs_routes.ts:14:88)
    at async normalized (deno::0::https://jsr.io/@fresh/core/2.1.1/src/commands.ts:21:1606)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/commands.ts:21:3255)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async eval (/home/arsga/Documents/code/WebstormProjects/fresh-project/main.ts:6:144)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async freshServeStaticFiles (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/static_files.ts:27:14)
    at async Context.fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async segmentMiddleware (deno::0::https://jsr.io/@fresh/core/2.1.1/src/segments.ts:13:1289)
    at async fn (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:453)
    at async eval (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:686)
    at async runMiddlewares (deno::0::https://jsr.io/@fresh/core/2.1.1/src/middlewares/mod.ts:6:55)
    at async Object.eval [as fetch] (deno::0::https://jsr.io/@fresh/core/2.1.1/src/app.ts:67:836)
    at async https://jsr.io/@fresh/plugin-vite/1.0.4/src/plugins/dev_server.ts:76:26
}

At another attempt it errored but recovered in a different place:

Shared value hello
6:12:44 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
6:12:44 PM [vite] (client) hmr update /assets/styles.css
6:12:44 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:12:44 PM [vite] (client) hmr update /components/Button.tsx
6:12:44 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:12:44 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
6:12:44 PM [vite] (client) hmr update /@id/fresh-island::Counter.tsx
6:12:44 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:12:44 PM [vite] Internal server error: The server is being restarted or closed. Request is outdated
      at throwClosedServerError (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:30780:32)
      at loadAndTransform (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:26140:66)
      at eventLoopTick (ext:core/01_core.js:179:7)
6:12:44 PM [vite] server restarted.
6:12:44 PM [vite] vite.config.ts changed, restarting server...
6:12:44 PM [vite] server restarted.
6:12:44 PM [vite] vite.config.ts changed, restarting server...
6:12:44 PM [vite] vite.config.ts changed, restarting server... (x2)
6:12:44 PM [vite] server restarted.

MonstraG avatar Oct 04 '25 16:10 MonstraG

Also, on a single save, I get this much logs:

➜  fresh-project git:(main) ✗ deno task dev
Task dev vite

  VITE v7.1.9  ready in 231 ms

  ➜  Local:   http://127.0.0.1:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
GET http://127.0.0.1:5173/
Shared value hello
6:15:00 PM [vite] vite.config.ts changed, restarting server...
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
6:15:00 PM [vite] (client) page reload client.ts
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (client) hmr update /assets/styles.css
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (client) hmr update /components/Button.tsx
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
6:15:00 PM [vite] (client) hmr update /@id/fresh-island::Counter.tsx
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (client) hmr update /@id/fresh-island::Counter.tsx
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] vite.config.ts changed, restarting server...
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
6:15:00 PM [vite] (client) page reload client.ts
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (client) hmr update /assets/styles.css
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (client) hmr update /components/Button.tsx
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry
6:15:00 PM [vite] (ssr) hmr update /@id/fresh:server_entry (x2)
GET http://127.0.0.1:5173/
Shared value hello
6:15:00 PM [vite] Internal server error: The server is being restarted or closed. Request is outdated
      at throwClosedServerError (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:30780:32)
      at EnvironmentPluginContainer.transform (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:31001:65)
      at eventLoopTick (ext:core/01_core.js:179:7)
      at async loadAndTransform (/home/arsga/Documents/code/WebstormProjects/fresh-project/node_modules/.deno/[email protected]/node_modules/vite/dist/node/chunks/dep-Chhhsdoe.js:26143:26)
6:15:00 PM [vite] server restarted.

This doesn't feel right, especially the vite.config.ts changed

MonstraG avatar Oct 04 '25 16:10 MonstraG

Also it creates those: Image

And if it dies, it doesn't clean it up. I guess that what makes it think that vite config changed

MonstraG avatar Oct 04 '25 16:10 MonstraG

The only way I can explain this my head is that your system somehow manages to trigger HMR in an extremely fast loop. E.g. one save in your editor somehow results in several (tens or hundreds even?) of HMR triggers. Re-writing a file in chunks might trigger this.

Can you please check that you see the same behavior/crash with other editors or even "manual" HMR triggers from the command line with:

touch assets/styles.css

fry69 avatar Oct 04 '25 16:10 fry69

➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
➜  fresh-project git:(main) ✗ touch assets/styles.css
GET http://localhost:5173/
Shared value hello
6:23:22 PM [vite] (client) hmr update /assets/styles.css
GET http://localhost:5173/
Shared value hello
6:23:25 PM [vite] (client) hmr update /assets/styles.css (x2)
GET http://localhost:5173/
Shared value hello
6:23:28 PM [vite] (client) hmr update /assets/styles.css (x3)
GET http://localhost:5173/
Shared value hello
6:23:29 PM [vite] (client) hmr update /assets/styles.css (x4)
GET http://localhost:5173/
Shared value hello
6:23:31 PM [vite] (client) hmr update /assets/styles.css (x5)
GET http://localhost:5173/
Shared value hello
6:23:32 PM [vite] (client) hmr update /assets/styles.css (x6)
GET http://localhost:5173/
Shared value hello
6:23:33 PM [vite] (client) hmr update /assets/styles.css (x7)
GET http://localhost:5173/
Shared value hello
GET http://localhost:5173/
Shared value hello
6:23:39 PM [vite] (client) hmr update /assets/styles.css (x8)
GET http://localhost:5173/
Shared value hello

I generally use WebStorm, and that dies, but Kate also kills it. nano is fine. micro is also fine. Zed fine vim dies.

MonstraG avatar Oct 04 '25 16:10 MonstraG

Since HMR get handled by Vite and that also receives those file change events, I think you want to report it there and see if they can add some kind of debounce logic for trigger happy systems/editors? -> https://github.com/vitejs/vite

fry69 avatar Oct 04 '25 16:10 fry69

Since HMR get handled by Vite and that also receives those file change events, I think you want to report it there and see if they can add some kind of debounce logic for trigger happy systems/editors?

Yep, got their preact template, reproduced:

6:32:57 PM [vite] vite.config.ts changed, restarting server...
6:32:57 PM [vite] changed tsconfig file detected: /home/arsga/Downloads/vite-project/tsconfig.json - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values.
6:32:57 PM [vite] (client) page reload index.html
6:32:57 PM [vite] (client) page reload src/main.tsx
6:32:57 PM [vite] (client) hmr update /src/app.css
6:32:57 PM [vite] (client) hmr update /src/app.tsx
6:32:57 PM [vite] (client) hmr update /src/index.css
6:32:57 PM [vite] (client) hmr update /src/app.tsx
6:32:57 PM [vite] server restarted.
6:33:27 PM [vite] (client) hmr update /src/index.css
6:33:28 PM [vite] (client) hmr update /src/index.css (x2)
6:33:29 PM [vite] (client) hmr update /src/index.css (x3)
6:33:29 PM [vite] (client) hmr update /src/index.css (x4)
6:33:29 PM [vite] (client) hmr update /src/index.css (x5)
6:33:29 PM [vite] (client) hmr update /src/index.css (x6)

(first half is Kate, second is micro)

MonstraG avatar Oct 04 '25 16:10 MonstraG

Fresh is a heavy Vite plugin that might surface this problem more than other plugins, those may be able to handle such event storms. There is little Fresh can do except adding everywhere try/catch/ignore blocks and hide this problem.

I'd vote for handling it upstream for now. If the Vite maintainers say that plugins have to deal with such event storms, this can get looked into again here.

fry69 avatar Oct 04 '25 16:10 fry69

Hmm, sorry but no, vite doesn't seem to be the problem.

Just in case I tried pnpm create vite (preact, and then defaults) and deno init --npm vite (preact, then defaults) and pnpm is perfectly fine with only 1 hmr per save. It's actually only reproduces with deno. Should I create an issue in denoland/deno?

MonstraG avatar Oct 04 '25 16:10 MonstraG

(preact, then defaults) and pnpm is perfectly fine with saves. It's actually on deno side.

I still think those other plugins are much more lightweight and can handle this, unlike Fresh.

Should I create an issue in denoland/deno?

Feel free.

fry69 avatar Oct 04 '25 16:10 fry69

I think it was already reported actually: https://github.com/denoland/deno/issues/27558.

MonstraG avatar Oct 04 '25 16:10 MonstraG

I think it was already reported actually: denoland/deno#27558.

Well, does

deno upgrade 2.1.1

fix this problem for you? Otherwise, the last message in that issue may point in the direction that multiple issues are at work here.

FYI: Fresh might not be compatible with that version 2.1.1, but you may be able to test other Vite plugins with it.

fry69 avatar Oct 04 '25 16:10 fry69

I think it was already reported actually: denoland/deno#27558.

Well, does

deno upgrade 2.1.1

fix this problem for you?

(Fresh might not be compatible with that version, but you may be able to test other Vite plugins with it)

simple vite template doesn't run, crypto.hash is not a function :(

MonstraG avatar Oct 04 '25 17:10 MonstraG

Well, I'm not that easily deterred, I've manually replaced crypto.hash call with Math.random, server started, and yes, hmr works just fine!

MonstraG avatar Oct 04 '25 17:10 MonstraG

I get the same error. It seems to happen for me if too many hmr updates are triggered.

vim triggers 50+ hmr updates on the styles.css, where vscode only triggers 5 or so

aSoaked avatar Oct 05 '25 11:10 aSoaked

Upstream issue https://github.com/denoland/deno/issues/27558

marvinhagemeister avatar Oct 05 '25 11:10 marvinhagemeister