Skip to content
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

Shiny Client Errors: Cannot read properties of null (reading 'deps') #128

Open
pawelru opened this issue Sep 3, 2024 · 4 comments
Open

Comments

@pawelru
Copy link

pawelru commented Sep 3, 2024

https://shinylive.io/r/editor/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAGwEsAjAJykYE8AKcqajGIgEwCu1OAGcMAcwpxm1AJQAdCHSYsOo1CwDWdCHEUQlaVAAIAPAFoTtCLVLslJk-yikoJgLwmu1APou3dgBJLCCAZU9rRlpROVxHEz4hEVFIpOExBwgnJ1IYXwA3FlooehFfJiIAd1EZBzAANWLSkRMAIUZq2sYFMAMnAwMlUQALG1YAQXR2YwASQVpcEznugpkDMABfAF0gA

I think it's due to this change in the htmlwidgets: r-wasm/htmlwidgets@892798f

console log

shiny.min.js:2 TypeError: Cannot read properties of null (reading 'deps')
    at shinyBinding.renderValue (htmlwidgets.js:515:44)
    at e.<anonymous> (shiny.min.js:2:174316)
    at m (shiny.min.js:2:166780)
    at Generator.<anonymous> (shiny.min.js:2:168103)
    at Generator.next (shiny.min.js:2:167139)
    at R_ (shiny.min.js:2:172750)
    at s (shiny.min.js:2:172948)
    at shiny.min.js:2:173009
    at new Promise (<anonymous>)
    at e.<anonymous> (shiny.min.js:2:172889)

When I enter the JS debugger I can see the following:
image
data is null thus data.deps throws

Outside of shinylive everything is fine. Entering debugger in the same place does not show null value.

I'm trying to create a base shiny example for this to debug this easier but the example above shows that it is possible to have null value there so it would make sense to handle this somehow.

I have seen #124 but adding loading dependency from external CDS does not help.

@pawelru
Copy link
Author

pawelru commented Sep 3, 2024

similar issue: r-wasm/webr#330

@pawelru
Copy link
Author

pawelru commented Sep 3, 2024

Minimal reprex

https://shinylive.io/r/editor/#code=NobwRAdghgtgpmAXGKAHVA6ASmANGAYwHsIAXOMpMAGwEsAjAJykYE8AKAZwAtaJWAlAB0IdJiw71OY4aIbM27ACIAVWSICutAAQAeALTbUUAOZwA+p1oATOPRbsR27Vdv3G2gLwubdh0+dtAm44AgBreiIADwBJCFQNUkcIQMC+BNIY6y9tITBGOABHPNwA1OooejhqHLyCwu0ANyhqDTgSssDm1rgcgDEAQQAZAGUAUU7ZZwFSlO1VAHlEjPYiZcSs2rAovNl1CE44RkajvUMAMw0IAlJaEnZ0xNxtNdIMgW0QANeMgBIos7aAoQWyMVTsL5zZz1B7xRK-epTNKMWicAIAX1k6JEIh4fFYA3Q7C0OS0z0Ox1O3gpJ0YsjA6IAukA

library(shiny)
library(bslib)
library(DT)

ui <- page_sidebar(
  sidebar = sidebar(
    checkboxInput(
      inputId = "req",
      label = "req value",
      value = FALSE
    )
  ),
  DTOutput(outputId = "x")
)

server <- function(input, output) {
  output$x <- renderDT({
    req(input$req)
    iris
  })
}

shinyApp(ui = ui, server = server)

@georgestagg
Copy link
Collaborator

I believe I have tracked down the underlying issue. That is, I now know how and why the problematic null object is being generated.

The issue is related to the patches made to webR's distribution of Shiny so that it can work well under WebAssembly. I have fixed the problem and made a new release of the package at https://github.com/r-wasm/shiny/releases.

With this latest build, the example app works without generating any errors:
Screenshot 2024-09-06 at 09 17 20

Shinylive won't automatically pick up the change, but I will include upgrading the Shiny R package as part of some other work I am currently undertaking. Once that work has all been merged, it should fix the issue on shinylive.io etc.

@georgestagg
Copy link
Collaborator

The above reprex (here) should now run successfully without errors on shinylive.io when toggling the req() switch.

The associated PR for the R Shinylive package to include the latest version of the assets is here: #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants