amberframework / amber

A Crystal web framework that makes building applications fast, simple, and enjoyable. Get started with quick prototyping, less bugs, and blazing fast performance.
https://amberframework.org
MIT License
2.57k stars 205 forks source link

Increase reliability of "amber exec" output #1269

Closed richardboehme closed 2 years ago

richardboehme commented 2 years ago

Description of the Change

When the code passed to "amber exec" outputs right before exiting, the output may not be written completely sometimes. This is due to the 1 millisecond delay in the loop when reading the output.

To fix this we just add a millisecond delay after the code exited, so that the output loop can finish.

Alternate Designs

I thought about printing the output on exit, however for a longer program this does not make sense. Moreover, it might be possible to store the handle to the opened file and read everything that was not read yet on program exit. However this seemed like a more complex change that I did not want to approach.

Benefits

Especially when the code passed to "amber exec" includes a compile-time error, the error was often not showed (at least on my machine). Having all errors (or other output) is the clear benefit of this PR.

Possible Drawbacks

The execution time is one millisecond longer than normal.

elorest commented 2 years ago

Thanks. I've merged it.