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

Reload the page on stale output? #1136

Open
vemv opened this issue Jul 25, 2023 · 5 comments
Open

Reload the page on stale output? #1136

vemv opened this issue Jul 25, 2023 · 5 comments

Comments

@vemv
Copy link

vemv commented Jul 25, 2023

Although it's fairly easy to make sense of the following message:

image

...it seems a little too high-friction of an scenario:

  • I have to realise that my index.html has a problem at all
    • I may be focused elsewhere: IDE, terminal, etc
  • I have to refresh the page
    • it's repetitive, and there's no other possible course of action for me

Because the fix is always the same, it seems reasonable to me to try automating it.

What would you think of an opt-in option that issued a location.reload() whenever output was stale?

...Perhaps there's some edge case under which the page would reload indefinitely. Which however could be quite trivially prevented by waiting 1.5s prior to to a refresh. That way, the browser is never possibly left busy-spinning.

Thanks - V

@thheller
Copy link
Owner

I'm more interested in hearing what you are doing, that leads you to this message in the first place? I don't see that message often and in all cases and automated reload loop would not fix it? Do you see this often?

Adding a reload is trivial, but I'd first want to figure out why you are seeing this in the first place and if there are maybe better solutions?

@vemv
Copy link
Author

vemv commented Jul 25, 2023

Thanks for the response!

I appreciate the caution.

I see this message when I:

  • shadow-cljs watch app
  • open index.html
  • Ctrl-C the first step
  • shadow-cljs watch app again
  • observe the already-open index.html

@thheller
Copy link
Owner

Why ctrl+c in the first place?

@vemv
Copy link
Author

vemv commented Jul 26, 2023

It is my habit to Ctrl-C any processes whenever I start my work day (or other similar conditions e.g. I restart work after a good pause or after switching 'contexts', e.g. branches).

It's a simple way of ensuring that I'm not accumulating state that might produce odd issues somewhere in the stack.

It might sound like a strage habit to some, however my life has only been happier since adopting it.

Either way, Ctrl-C is a relatively common operation, for example think of adding dependencies.

@jacobemcken
Copy link

jacobemcken commented Aug 7, 2023

I have a build setup specifically for Storybook:

{:source-paths ["src/frontend" "src/storybook"]
  ...
  :storybook
  {:target :npm-module
   :as-regexp "-stories$"
   :output-dir "resources/public/js/storybook"}}}

When I create new files in src/storybook matching the regex stories$ they aren't picked up until I restart Shadow-cljs. But that might be another defect?

The most common reason to restart Shadow-cljs for me is that I don't understand much of what is actually happening under the hood. Is something cached, did I do something wrong without even knowing? So when I deal with a problem I don't understand, one of the attempts to solve it is restarting the other thing that I don't understand - just to make sure that I ain't caught for hours with a problem that could be solved following the wisdom:

Did you try to turn it off and on again?

I agree that restarting should be avoided at all costs.

Though, every time I see "Stale output"... reloading the browser has always worked. This makes me think:
If the application knows it needs a reload... why does it need me to do it?
Again I don't understand a lot of this... but that is the question that pops into my head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants