object '.dependents' not found

I'm trying to construct an arrow query inside of a shiny server function, and running into the error object '.dependents' not found, which appears to be coming from the R6 OOP system (e.g. Reactive within R6 classes throws .dependents not found error · Issue #137 · r-lib/R6 · GitHub).

Here's a reprex, where data2 creates the error:

library(shiny)
library(dplyr)
library(arrow)

arrow::write_dataset(iris[-1, ], "iris.parquet")

ui <- fluidPage(
  fluidRow(
    selectInput(
      inputId = "species",
      choices = unique(iris$Species),
      selected = "setosa",
      multiple = TRUE,
      label = "Species"
    )
  ),
  fluidRow(h2("data:"), DT::DTOutput("data")),
  fluidRow(h2("data2:"), DT::DTOutput("data2"))
)


server <- function(input, output, session) {
  con = arrow::open_dataset("iris.parquet")

  output$data =
    con |>
    filter(Species %in% input$species) |>
    collect() |>
    DT::renderDataTable()

  # why doesn't this work?
  cur_species = reactive(input$species)
  output$data2 =
    con |>
    filter(Species %in% cur_species()) |>
    collect() |>
    DT::renderDataTable()


}

shinyApp(ui, server)

Supposing I'm committed to creating cur_species as an intermediate reactive (because in my actual application, computing cur_species requires multiple complicated steps): is there a way to make this approach work? Thanks for any advice!

You don't have a shiny issue but a pure arrow/dplyr issue. This can be demonstrated from the following minimal example :

library(dplyr)
library(arrow)

arrow::write_dataset(iris[-1, ], "iris.parquet")
con = arrow::open_dataset("iris.parquet")

ch <- unique(iris$Species) 

con |>
  filter(Species %in% ch) |>
  collect() 
Error in `compute.arrow_dplyr_query()`:
! Type error: Array type doesn't match type of values set: string vs dictionary<values=string, indices=int32, ordered=0>

it seems iris dataset Species field is to arrow a dictionary type where a string is associated with a numeric index, which makes sense as that broadly describes factor types which iris$Species is.
within the dplyr::filter expression, we try to match on a similar factor variable; I dont know why this is a problem, but it seems to be. a convenient fix would seem to be to just have the field be a plain string, and match on strings.

library(dplyr)
library(arrow)

iris_string_no_fact <- iris |> mutate(across(where(is.factor),as.character))

arrow::write_dataset(iris_string_no_fact, "iris.parquet")
con = arrow::open_dataset("iris.parquet")

ch <- as.character(unique(iris_string_no_fact$Species) )

con |>
  filter(Species %in% ch) |>
  collect()