I’m wondering if anyone has run into this before as this has now happened twice.
Whenever I save a file, the project recompiles twice, sometimes three times. This is particularly frustrating with live reload on as it fires each time causing multiple page “reloads” (ie, topbar fires multiple times).
Has anyone run into this before? In the past, updating Phoenix seemed to fix it, but I’m on latest and going through some bisect hell trying to figure out what caused this so thought I’d ask here if it’s a common problem.
This has happened to me when I accidentally load the live-reload javascript in the HTML multiple times. I’d open your browser and check and see if you’ve got multiple reload websockets open, that’s a sure sign that it’s running multiple instances in your browser.
1 Like
I’ve been using that a bunch this past week on another project to diagnose slow compilation times (to great success!) but did not think to use it here because it’s not recompiling multiple files, it just seems to be compiling multiple times. I just tried mix xref graph --sink lib/my_app/some_file.ex --label compile
on some files anyway and I’m clean!
This sounds so familiar! I feel like last time this happened I may have had two copies of the app open, but that wasn’t the case this time. I finally tried the ol’ turn-it-on-and-off-again which of course now has me dealing with some postgres problem because this is an older computer I haven’t restarted in a while, ha, oh boy.
So postgres is fixed, I definitely don’t have multiple websocket connections and it’s still happening. I’ll have to dig into bisectting more, I’ve just made a lot db changes along the way so it’s annoying and I really just want to get back to actual work. I just asked here in case someone could be like, “It’s this!”
Thanks for the replies, everyone!
EDITED to add:
I found the post where someone gave an answer that solved this for me before. The solution was to upgrade esbuild. Esbuild has moved well past that version. Upgrading to latest doesn’t solve it and I can’t try downgrading to the version specified in that post as it’s no longer available.
OK, scratch that… this post did solve my problem, I just didn’t do it properly. I only upgraded the esbuild package but didn’t touch the version number in config/config.exs
.
However, I don’t understand this. If I put 0.4.0
in config/config.exs
, I get a warning: expecting esbuild version 0.4.0 but got .
(ie, blank version). If I change the config/config.exs
value to 0.13.5
(mix version is still 0.4.0
) then everything works just fine. I’m pretty confounded by this…
EDITED to add: wait no, that makes sense. The hex package version and esbuild versions are not tied… adoi!
5 Likes
I have something similar.
When saving a file, the building and recompilation ist super fast (if I can trust the terminal logs…)
But then the browser starts reloading and takes top to 6 to 12 seconds.
In the past this was extremely fast. reload was done right away…
I cannot find any bottlenecks so far.
If I just hit save, without changing anything in the .ex file, everything is fast as hell. As soon as there is a change, it takes much more time…
What I figured out, that it is faster on some files, and takes much longer on other files.
But no idea why and no fix for that yet.
You might want to try it with another browser. If it loads blazing fast in the second browser, you might want to look in the browsers (session) storage and clear it out.
If that solves the issue, search for “liveview longpoll server restart”.