Minor progress bar infelicity
I am loving the new progress bar! But I noticed a couple of small issues exemplified by this simple Rmd:
```{r alpha}
Sys.sleep(0.5)
```
```{r bravo}
Sys.sleep(0.5)
```
```{r charlie}
Sys.sleep(5)
```
After alpha and bravo have completed and charlie is still running, I see this:
Two small problems:
- Weirdly, the
processingmessage appears part way in the middle of the progress bar - The progress bar shows 100% complete even though we're still working on chunk 3.
By filing an issue to this repo, I promise that
- [x] I have fully read the issue guide at https://yihui.org/issue/.
- [x] I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
xfun::session_info('knitr'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr'). - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
Even more nitpicky, I noticed that if I run rmarkdown::render() there are two blank lines before the progress bar starts:
> rmarkdown::render("delay.Rmd")
processing file: delay.Rmd
|........................ | 33% (alpha)
And maybe there's one extra empty line at the bottom too? (at least when run_pandoc = FALSE).
> invisible(rmarkdown::render("delay.Rmd", run_pandoc = FALSE))
processing file: delay.Rmd
output file: delay.knit.md
>
Hmmm, the first problem (where "processing..." is interleaved in the output") might actually be an RStudio problem
It is an RStudio bug: https://github.com/rstudio/rstudio/issues/8160. knitr could work around it by outputing the "Process file" message to stdout() instead of stderr(). We have some techniques to do this in rlang/cli, but you could also just switch the message() to cat().
@kevinushey pointed me to this article on why interleaving streams is generally hard: https://unix.stackexchange.com/questions/476080/what-prevents-stdout-stderr-from-interleaving/476089#476089. You might also argue that maybe the problem is that the progress bar is using stdout() since everything that appears in this display will be using stderr()
Not 100% sure this is the same problem, but note that in this connnect log the progress bar shows up after the error.
This is almost surely an RStudio issue -- not sure if there's a way to replicate the same flow in a "regular" R instance outside of RStudio.