amber
amber copied to clipboard
[CLI] Shutdown server in watch when compilation fails
Amber watch makes it almost transparent that the server is actually rebooting, and I love that. The behavior to allow the server to continue running while new code compiled and hotswap the instances is very helpful.
However, when iterating quickly, I sometimes find that I miss an error message and since the old code is still running, I think it all works fine.
My idea for this situation is one of two possibilities:
- kill the server, but not the watch. Let the fact that the webpage is no longer responding signal to the dev that they should check for compilation errors.
- display some sort of notification to the dev. My mind goes to a growl type notification, but I think growls heyday has come and gone.
- to kill the server, and start a page which displays the stack trace.
Either way, continue to watch files and recompile changes, and when it works, start the server.
I ran into this myself today, and I think I saw someone in Gitter hit it too.
Thoughts?
I think we can save the error output in a temp file, then the browser (client reload script && Reload pipeline) watch this file and shows a message.
Most frameworks do it because they're run-time languages with run-time errors.
Crystal & Amber are compiled, so we need to implement something like Phoenix error page, but for compile time errors:

I have been using ASP.NET for some weeks and I notice that in Net framework compilation errors are shown in browser, so, I think we can try to send compilation errors to the browser and reload it automatically when code is fixed and compilation pass, WDYT?
That’s fine with me, all I want is for an out of date page to not keep showing up when compilation fails.
An user on IRC #amber community channel has suggested to use similar design to elixir error pages
https://github.com/elixir-plug/plug/pull/423

^ I like it :heart:
WDYT?
Lets go for it as long we have permission and the author is ok with it we can add the amber logo and make some tweaks to the design.
Lets go for it as long we have permission and the author is ok with it we can add the amber logo and make some tweaks to the design.
I already sent and email to @rstacruz :smile:

^^ Compile time error in the browser :tada:
I ported the Elixir template to Embedded Crystal, also I tweaked some things and added new features like Reload browser automatically and See raw message.
Finally we will be able to see both compile-time and run-time errors in the browser :wink:
I'll open some PRs soon
@faustinoaq Any chance you will have some time to work on this? We have the new exceptions page but if there is an error in compilation, the existing process is not killed and no error is displayed.
Since the amber-watch config is merged in, @anamba may be the one with the most recent experience in the area. Any chance you'd like to contribute to this one?