-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timezone is unset after 2nd visit to Shiny app #3741
Comments
Huh, weird, this appears to be some strange interaction with shiny....I can render a page statically without encountering the issue: library(shiny)
library(bslib)
library(htmltools)
Sys.setenv(TZ = "America/Sao_Paulo")
ui <- fluidPage(
theme = bs_theme(
version = 5,
primary = "#002FA7"
),
"Foo bar"
)
browsable(ui)
Sys.getenv('TZ')
#> [1] "America/Sao_Paulo" |
I was able to reproduce this by running the app twice. Note that, at first, # Initially, TZ is not set
Sys.getenv("TZ", unset = "UNSET")
#> [1] "UNSET"
# Set to some value
Sys.setenv(TZ="America/Chicago")
Sys.getenv("TZ", unset = "UNSET")
#> [1] "America/Chicago"
library(shiny)
ui <- fluidPage(theme = bslib::bs_theme())
server <- function(input, output, session) {
stopApp() # Close the app as soon as the browser connects
}
app <- shinyApp(ui, server)
# Run first time: No change
app
Sys.getenv("TZ", unset = "UNSET")
#> [1] "America/Chicago"
# Run second time: TZ is set to ""
app
Sys.getenv("TZ", unset = "UNSET")
#> [1] ""
|
I'm also finding that:
The fact that it happens on the second visit makes me wonder if it has something to do with bslib or sass's caching mechanism. |
FWIW, it doesn't seem related to caching since I can repro with setting |
After some more investigation, It appears as though this issue is not specific to bslib (or sass). It can be reproduced with a fairly simple library(shiny)
library(htmltools)
Sys.getenv("TZ", unset = "UNSET")
#> [1] "UNSET"
Sys.setenv(TZ = "America/Chicago")
writeLines("body{background: red}", "styles.css")
dep <- htmlDependency(
"foo", "1.0",
src = getwd(),
stylesheet = "styles.css",
all_files = FALSE
)
app <- shinyApp(div(dep), \(...) stopApp())
app
Sys.getenv("TZ", unset = "UNSET")
#> [1] "America/Chicago"
app
Sys.getenv("TZ", unset = "UNSET")
#> [1] "" |
rstudio/httpuv#300 also seems to be relevant here. Particularly this line |
# httpuv 1.6.9 * Fixed #354: The incorrect method was called to clear a `vector`. (#355) * The `src/Makevars` file no longer sets `CXX_STD=CXX11`, and the `DESCRIPTION` file no longer lists `SystemRequirements: C++11`, because newer R versions always support C++11. (#356, #357) # httpuv 1.6.8 * Fixed #351: A race condition could cause httpuv to crash when starting the background thread for I/O. (#352) # httpuv 1.6.7 * Fixed rstudio/shiny#3741: The `TZ` environment variable could get unset in some cases. (#346) * Closed #302: Fixed potential thread-safety issues with `timegm2` implementation. (#346) # httpuv 1.6.6 * Update docs for CRAN (#343) * Updated to libuv 1.43.0. (#328) * Fixed #336: `encodeURI()` and `encodeURIComponent()` printed a space instead of a leading zero, as in `"% A"` instead of `"%0A"`. (#337)
Describe the problem
Running a Shiny app that uses
bslib
twice will unset myTZ
environment variable. For example, when I restart my R session,Sys.getenv('TZ')
shows that I have a correctly set timezone. Then if I source the following code, hit escape to stop the app, and then run the app again, thenSys.getenv('TZ')
returns""
.If I try this with a skeleton app without the
theme
then I do not have this timezone problem.Session Info
The text was updated successfully, but these errors were encountered: