Comments (14)
I'm missing some context here but if you do decide to set the shiny.suppressMissingContextError
option, please make sure to restore its previous value when you're done.
from lobstr.
Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you!
If you've never heard of a reprex before, start by reading "What is a reprex", and follow the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.
from lobstr.
Can't use reprex
for the case 1 because it runs forever.
Case 1:
# devtools::install_github('beauchamplab/rave@rave-fir')
library(rave)
library(lobstr)
# rave::download_subject_data('https://s3-us-west-2.amazonaws.com/rave-demo-subject/sfn-demo/data-large.zip')
m = unlist(load_modules())[[3]]
init_app(m, test.mode = T)
ref(m)
Error message:
'as.list.reactivevalues' is deprecated. Use reactiveValuesToList instead.
Please see ?reactiveValuesToList for more information.
Error in .getReactiveEnvironment()$currentContext() :
Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Second case doesn't go well with reprex
as well since the shiny app didn't launch.
suppressPackageStartupMessages(library(shiny))
env = new.env()
shinyApp(fluidPage(actionButton('asd',' ')), server = function(input,output,session){
local_data = reactiveValues(a=1)
env$sess = session
stopApp()
})
Shiny applications not supported in static R Markdown documents
lobstr::ref(env$sess)
#> [1:0x7fada201e2e0] <NULL>
Created on 2018-12-05 by the reprex package (v0.2.1)
If I ran without reprex
, then the error message is:
> lobstr::ref(env$sess)
Error in is.character(lhs) :
C stack usage 7970736 is too close to the limit
Error during wrapup: C stack usage 7969856 is too close to the limit
from lobstr.
Can you please give me some snippet off code to run that doesn't require installing other packages or installing large data? It should be possible to make a very small shiny app to demonstrate the problem.
from lobstr.
I can reproduce the issue with the code above, though the error message is different now.
> lobstr::ref(env$sess)
Error in is.character(lhs) : node stack overflow
This part might be done with shiny:::ShinySession$new(ws)
, but I'm yet to find what ws
I should pass...
env$sess = session
from lobstr.
@jcheng5 should be able to help you figure it out
from lobstr.
I can reproduce the issue with the code above
Sorry, I just looked at the second issue... 🙄
For the first case, @jcheng5 suggested (thanks!) we can use options(shiny.suppressMissingContextError=TRUE)
to suppress the error.
For the second case, it seems there's a ciruclation of reference:
> unclass(env$sess$.__enclos_env__)
<environment: 0x00000197c79482c0>
> unclass(env$sess$.__enclos_env__$self$.__enclos_env__)
<environment: 0x00000197c79482c0>
from lobstr.
For the second case, it seems there's a ciruclation of reference
Sorry, this is not the core of the problem, it seems package_version
(env$sess$request$httpuv.version
) is the problem:
> lobstr::ref(package_version("0.0.1"))
Error in is.character(lhs) : node stack overflow
from lobstr.
@yutannihilation do you want to have a look at why this is a problem? I suspect it's because:
x <- package_version("0.0.1")
identical(x, x[[1]])
#> [1] TRUE
Created on 2019-01-19 by the reprex package (v0.2.1.9000)
So we need to use .subset2()
instead of [[
from lobstr.
Yes, I'd like to (but maybe not today...).
from lobstr.
No problems, the most important thing is the reprex 😄
from lobstr.
It seems you are right; ref_tree()
is applied infinitely here because lapply(<package_version>, f)
passes the newly generated package_version
, not its elements, to f()
.
Line 57 in 9fcf642
The problem is [[.numeric_version()
creates a new object, so it never matches the addresses in seen
.
library(lobstr)
x <- package_version("1.0.0")
obj_addr(x)
#> [1] "0x156f7138"
obj_addr(x[[1]])
#> [1] "0x17f49378"
obj_addr(x[[1]])
#> [1] "0x17f6d648"
Created on 2019-01-25 by the reprex package (v0.2.1)
Using .subset2()
might be an idea, but I think it's not always possible to know the "correct" length of the object to generate indices, because length()
might tell us some wierd value.
Instead, how about unclass()
in all these recursive cases? Since we are looking into the underlying structure, we don't need custom classes and methods. This means we can avoid calling such methods as as.list.reactiveValues()
, so I feel this fix is more general.
Lines 55 to 62 in 9fcf642
If this looks OK, I'll create a PR.
from lobstr.
Yeah, that sounds right to me.
from lobstr.
Thanks, I created #36.
BTW, I didn't know environments cannot be unclassed...
e <- structure(new.env(), class = "foo")
class(e)
#> [1] "foo"
unclass(e)
#> Error in unclass(e): cannot unclass an environment
Created on 2019-01-26 by the reprex package (v0.2.1)
from lobstr.
Related Issues (20)
- Release lobstr 1.1.0
- Release lobstr 1.1.1
- Use the ALTREP inspect method in sxp
- modify ast tree HOT 1
- obj_sizes gives NA for objects larger than 2^31 bytes
- Bad binding access HOT 22
- List R-core as contributor in DESCRIPTION HOT 1
- Request: make `ast()` not automatically unwrap quosures HOT 3
- List all parent environments for a given environment HOT 1
- obj_size() formatting for large objects
- Move `master` branch to `main` HOT 1
- `obj_size` returns different values before and after accessing an element HOT 4
- `format()` method for `lobstr_bytes` HOT 1
- Use consistent type abbreviations
- Release lobstr 1.1.2
- Switch to rlang bytes formatting to eliminate prettyunits dep
- Error for incorrect sxp expand argument does not print list of acceptable values
- Is the output of `ast` wrong for functions with a namespace? HOT 1
- Upkeep for lobstr (2022)
- Reference count seems to be off
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lobstr.