bhauman / figwheel-main

Figwheel Main provides tooling for developing ClojureScript applications
https://figwheel.org
Eclipse Public License 1.0
640 stars 93 forks source link

api/stop seems not to work for first build #264

Open jtkDvlp opened 4 years ago

jtkDvlp commented 4 years ago

Hi there,

I got the issue starting two or more build in serve mode and stopping them via api/stop per build and restarting later will cause an BindException Already in case for the first started and stopped build at the beginning.

user> (fig/start {:mode :serve} "A")
;; => nil
user> (fig/start {:mode :serve} "B")
;; => nil
user> (fig/stop "A")
;; => true
user> (fig/stop "B")
;; => true
user> (fig/start {:mode :serve} "A")
Execution error (BindException) at sun.nio.ch.Net/bind0 (Net.java:-2).
Address already in use

starting B works.

Any ideas, any one else got this issue?

PhenomDevel commented 3 years ago

I have the very same issue. In the docs it is mentioned that you have to stop all builds before the server will be stopped. After that the expected behavior would be to be able to restart the builds in serve mode again.

I noticed that only the server of the last build which is stopped is going to be stopped as well. Which means that the server for build A in your case is still running which leads to the Address already in use.

The fix for this would be to stop all servers associated with the stopped builds when there is no more build running.

jtkDvlp commented 3 years ago

Caused by waking up this issue I dived into the source code and now claim I found and fixed the issue. As @PhenomDevel already mentoined currently its just working for the lastest stopped build. Thats because the server of a build only will be stopped if there are no more builds running. But this condition resolves to all builds not the builds of the current builds server. Scoping this condition to the builds server fixes the issue.