Mwavu
Mwavu

Mwavu

Warning: Error in renderFunc: argument "shinysession" is missing, with no default [No stack trace available]

Photo by Abbas Tehrani on Unsplash

Warning: Error in renderFunc: argument "shinysession" is missing, with no default [No stack trace available]

Mwavu's photo
Mwavu
·May 27, 2022·

2 min read

TL;DR

Check:

  • downloadHandler()

  • renderUI()

Background

Spent around 45 minutes debugging this. It's just funny how simple it is to come up with a reprex.

I forgot to give a return value to a module server, yet I was observing it from it's caller. The last call from the module server was a downloadHandler() chunk.

After debugging I decided to test whether other render*() functions would also throw the error. Only renderUI() did.

Reprex

1. downloadHandler()

library(shiny)

# module UI:
mod1_ui <- function(id) {
  ns <- NS(id)

  # ----downloadHandler----
  tagList(
    tags$h3(
      "We're in mod1 UI"
    ),

    downloadButton(ns("download_here"), "Download")
  )
}

# module server:
mod1_server <- function(id) {
  moduleServer(
    id = id, 
    module = function(input, output, session) {
      # ----downloadHandler----
      # Our dataset:
      data <- mtcars

      output$download_here <- downloadHandler(
        filename = function() {
          paste("data-", Sys.Date(), ".csv", sep="")
        },
        content = function(file) {
          write.csv(data, file)
        }
      )
    }
  )
}

# app UI:
ui <- fluidPage(
  mod1_ui(id = "thismod")
)

# app server:
server <- function(input, output, session) {
  # Get return value from module server:
  k <- mod1_server(id = "thismod")

  # Observe changes in the return value:
  observeEvent(k(), {
    print("Didn't I throw an error!?")
  })
}

shinyApp(ui, server)

2. renderUI()

library(shiny)

# module UI:
mod1_ui <- function(id) {
  ns <- NS(id)

  # ----uiOutput----
  uiOutput(outputId = ns("ui_here"))
}

# module server:
mod1_server <- function(id) {
  moduleServer(
    id = id, 
    module = function(input, output, session) {
      # ----uiOutput----
      output$ui_here <- renderUI({
        tags$h3("UI Here!")
      })
    }
  )
}

# app UI:
ui <- fluidPage(
  mod1_ui(id = "thismod")
)

# app server:
server <- function(input, output, session) {
  # Get return value from module server:
  k <- mod1_server(id = "thismod")

  # Observe changes in the return value:
  observeEvent(k(), {
    print("Didn't I throw an error!?")
  })
}

shinyApp(ui, server)

Solution

In my case, the solution was returning the necessary reactive from the module server.

Yours might be different but I'm pretty sure checking any (or both) of those two in your code should point you in the right direction.

 
Share this