Skip to content

Commit 22de425

Browse files
authored
Fix: don't create .Random.seed as side effect of loading shiny (#4383)
Only call `httpuv::getRNGState()` when restoring a pre-existing `.Random.seed`, avoiding RNG state creation when none existed before. Fixes #4382
1 parent 929143f commit 22de425

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
This method was never called by Shiny's runtime, so any overrides were dead
2929
code. Use `unsubscribe()` for cleanup logic instead. (#4375)
3030

31+
## Bug fixes
32+
33+
* Loading shiny no longer creates `.Random.seed` in the global environment as a side effect. (#4382)
34+
3135
# shiny 1.13.0
3236

3337
## New features

R/utils.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ withPrivateSeed <- function(expr) {
7676

7777
if (hasOrigSeed) {
7878
.GlobalEnv$.Random.seed <- origSeed
79+
# Need to call this to make sure that the value of .Random.seed gets put
80+
# into R's internal RNG state. (Issue #1763)
81+
httpuv::getRNGState()
7982
} else {
8083
rm(.Random.seed, envir = .GlobalEnv, inherits = FALSE)
8184
}
82-
# Need to call this to make sure that the value of .Random.seed gets put
83-
# into R's internal RNG state. (Issue #1763)
84-
httpuv::getRNGState()
8585
})
8686

8787
expr

0 commit comments

Comments
 (0)