[BUG] is_running() returns FALSE while the app is running
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start in R/with_opt.R, where with_golem_options() sets the running flag and resets it with on.exit(), then look at is_running() and get_golem_options() to see how they read state. Run the reproduction in the issue and watch the console for is_running() at UI time. Test/test-is_running.R sets the global by hand, so the fix needs a test that serves the app. Done when is_running() returns TRUE inside a served app and that test passes.
Written by the indexing model from the issue text.
Description
Describe the bug
is_running() returns FALSE while a {golem} app is actually being served.
with_golem_options() sets the running flag, then resets it with on.exit() (R/with_opt.R#L40-L51). But with_golem_options() returns the shiny.appObj before shiny runs it (the app is started later by print() / runApp()), so the flag is always FALSE by the time the UI and server functions execute. The only exception is print = TRUE.
The current test (test-is_running.R) sets .golem_globals$running by hand, so it doesn't catch this.
To Reproduce
library(golem)
app <- with_golem_options(
app = shiny::shinyApp(
ui = function(request) {
message(
"is_running(): ", is_running(),
" | get_golem_options('title'): ", get_golem_options("title")
)
shiny::div()
},
server = function(input, output, session) {}
),
golem_opts = list(
title = "x"
)
)
shiny::runApp(
app,
port = 8765,
launch.browser = FALSE
)
Then open http://127.0.0.1:8765. The console shows:
is_running(): FALSE | get_golem_options('title'): x
Expected behavior
is_running() returns TRUE inside an app launched through with_golem_options().
Additional context
get_golem_options() works at runtime because the options are stored in app$appOptions. A possible fix is to derive the status from there, e.g. !is.null(shiny::getShinyOption("golem_options")), instead of a global flag. That would need a test that actually serves the app.
session info
R 4.3.3, Ubuntu 24.04, {golem} master (9938a41, version 1.0.1).
Generated by Claude Code
- Dominant language
- R
- Stars
- 947
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ThinkR-open/golem
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ThinkR-open/golem#1265 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ThinkR-open/golem#1259 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ThinkR-open/golem#1258 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
ThinkR-open/golem#1257 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ThinkR-open/golem#1256 ·
All issues in ThinkR-open/golem
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
leppott/BioMonTools#162 ·
-
publications
Difficulty 1/5 Under an hour Newbie friendliness 85/100
epiforecasts/epiforecasts.github.io#161 ·
Maintainers usually reply within 1 day
-
Label `{sas}` chunk source as `sas` instead of `txt`, so it gets syntax highlightingPossibly taken @michaelmayer2 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microbiome/OMA#1031 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
furrer-lab/abn#291 · 2 comments ·