yesodweb / yesod

A RESTful Haskell web framework built on WAI.
http://www.yesodweb.com/
MIT License
2.64k stars 374 forks source link

yesod-bin: yesod dev server can be made always in compile mode in some scenarios #1384

Open psibi opened 7 years ago

psibi commented 7 years ago

The current stack version of yesod-bin suffers from this bug in which a yesod development server can always show the "Refreshing page" even when it's built successfully. Step to reproduce:

It will go to compile mode permanently until you press "enter" again or type "rebuild".

The reason for this is that atomically $ writeTVar appPortVar (-1) is called whenever stack build process emits some output.

IMO, I think this is better fixed at the Stack tool itself by adding a new feature there. I will create a new issue in the Stack repo if other's agree.

snoyberg commented 7 years ago

No objection from me. How does this affect the PR you opened here?

psibi commented 7 years ago

Unfortunately my PR doesn't affect it in any way. With or without my PR, you can reproduce the issue in yesod devel. But I did found this issue while working on that PR.

snoyberg commented 7 years ago

What I'm trying to understand is whether that PR is worth continuing with on its own, or if it's better to try to solve both in one step with the added Stack feature.

psibi commented 7 years ago

It is worth continuing as the race condition cannot be solved in Stack itself (I'm open to ideas on how to fix that in the stack). This issue is independent of the other one.

The whole reason the race condition occurs is because of the interaction between the two concurrent process:

Since their interaction is only controlled via yesod-bin, It can be only fixed here.

snoyberg commented 7 years ago

Got it, thanks for the explanation.

psibi commented 7 years ago

I have added a PR for Stack implementing this required feature: https://github.com/commercialhaskell/stack/pull/3165