Skip to content

Don't fail in the shiny progress handler before the bar is shown (#762) - #846

Open
taekop wants to merge 1 commit into
r-lib:mainfrom
taekop:fix-shiny-progress-output
Open

taekop wants to merge 1 commit into
r-lib:mainfrom
taekop:fix-shiny-progress-output

Conversation

@taekop

@taekop taekop commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

cli_progress_output() errors with "attempt to apply non-function" under the Shiny progress handler when the bar hasn't been shown yet:

shiny::testServer(function(input, output, session) {
  id <- cli::cli_progress_bar(total = 10)
  cli::cli_progress_output("custom message", id = id)
}, {})

(with options(cli.progress_handlers_only = "shiny"); in a real app the handler is picked automatically.)

Bars are only added after cli.progress_show_after (2 seconds by default), and the handler's output() method called bar$shiny_progress$set(), but shiny_progress is only created in add(). So any output sent before that point hits NULL$set().

output() still records the text in bar$shiny_output, so it shows up once the bar is added; it just doesn't call set() until there is a Shiny progress object.

The new test in test-progress-handlers.R fails on main and passes here. I also tried output before and after the bar is shown, several outputs, cli_progress_message(), cli_progress_step() and finishing before the bar is ever shown; only the calls that used to error behave differently. The only failures in the full suite locally are the keypress() tests, which fail the same way on main.

I added shiny to Suggests for the test.

Closes #762

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

builtin_handler_shiny results in Error: attempt to apply non-function

1 participant