`builtin_handler_shiny` results in Error: attempt to apply non-function
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start with R/progress-server.R around lines 356-365 and inspect the lifecycle of builtin_handler_shiny, especially complete(), set(), and output(). Reproduce the post-completion call sequence described in targets issue 1478; done means the shiny handler no longer raises a non-function error when progress operations occur after completion.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Dear cli maintainer, I recently encountered an issue https://github.com/ropensci/targets/issues/1478 (please check this issue for more detailed examples)
The targets package probably tried using cli progress bar before initialized ("add") or after completion, resulting in an error. The related code is here
https://github.com/r-lib/cli/blob/main/R/progress-server.R#L356C1-L365C5
We see that shiny progress is set to NULL, and then trying to access functions such as output or set will raise errors.
bar$shiny_progress <- NULL
Basically if shiny ends the progress bar builtin_handler_shiny$complete() and the program still tries to call builtin_handler_shiny $output(), then the code will error out in shiny app. However, the code works fine outside of shiny, which makes the debugging process extremely hard.
I understand that if the package is used super carefully, then this issue will not occur. However, it is often the case that the package does not mandate what people do, especially when the code just works for most of people. Considering that other handlers do not raise errors on "use-after-free", and condition that triggers this error, this inconsistency is super hard to debug/find.
However, could we add checks just to make sure the functions are not that stringent? Alternatively, if you would like to ensure consistent behavior, we can force set and output to result in errors after completion for other functions.
builtin_handler_shiny <- list(
able = function(bar, .envir) {
"shiny" %in% loadedNamespaces() && asNamespace("shiny")$isRunning()
},
add = function(bar, .envir) {
bar$shiny_progress <- asNamespace("shiny")$Progress$new(
asNamespace("shiny")$getDefaultReactiveDomain(),
min = 0,
max = bar$total
)
bar$shiny_progress$set(
message = bar$name %||% "",
detail = shiny_detail(bar, .envir)
)
},
set = function(bar, .envir) {
if(!is.null(bar$shiny_progress)) {
bar$shiny_progress$set(
value = bar$current,
detail = shiny_detail(bar, .envir)
)
}
},
complete = function(bar, .envir, results) {
if (!is.null(bar$shiny_progress)) {
bar$shiny_progress$set(
value = bar$current,
detail = shiny_detail(bar, .envir)
)
bar$shiny_progress$close()
}
bar$shiny_progress <- NULL
},
output = function(bar, .envir, text) {
bar$shiny_output <-
last_lines(paste0(bar$shiny_output, " \u2022 ", text))
if(!is.null(bar$shiny_progress)) {
bar$shiny_progress$set(
value = bar$current,
detail = shiny_detail(bar, .envir)
)
}
}
)
- Lenguaje dominante
- R
- Estrellas
- 730
- Forks
- 95
- Merge medio
- 5 d 32 min
- PR fusionados (30 d)
- 5
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de r-lib/cli
-
C function cli_progress_sleep() is used in an example but not documented.Posiblemente ocupada @shreyabyte la tomó hace 53 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
-
`pb_elapsed` should not show minutes & fractions of secondsPosiblemente ocupada @mcol la tomó hace 407 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
feat: add `.duration` and `.time_ago` inline stylesPosiblemente ocupada @jjjermiah la tomó hace 169 días. Abiertofeature
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
-
docs: provide llms.txtAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
Issues similares
-
How is TSS clculated by biomod2Abiertomodeling question
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
eduaguilera/whep#1489 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Manual of AZTrees out of dateAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 94/100
tdhock/mlr3resampling#107 ·
-
Warning from lst() : object length is not a multiple of subscript lengthPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100