{"action":"created","issue":{"url":"https://api.github.com/repos/rstudio/shiny/issues/1125","repository_url":"https://api.github.com/repos/rstudio/shiny","labels_url":"https://api.github.com/repos/rstudio/shiny/issues/1125/labels{/name}","comments_url":"https://api.github.com/repos/rstudio/shiny/issues/1125/comments","events_url":"https://api.github.com/repos/rstudio/shiny/issues/1125/events","html_url":"https://github.com/rstudio/shiny/issues/1125","id":138474473,"number":1125,"title":"Issue with \"hidden error\" when using eventReactive","user":{"login":"daattali","id":952340,"avatar_url":"https://avatars.githubusercontent.com/u/952340?v=3","gravatar_id":"","url":"https://api.github.com/users/daattali","html_url":"https://github.com/daattali","followers_url":"https://api.github.com/users/daattali/followers","following_url":"https://api.github.com/users/daattali/following{/other_user}","gists_url":"https://api.github.com/users/daattali/gists{/gist_id}","starred_url":"https://api.github.com/users/daattali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daattali/subscriptions","organizations_url":"https://api.github.com/users/daattali/orgs","repos_url":"https://api.github.com/users/daattali/repos","events_url":"https://api.github.com/users/daattali/events{/privacy}","received_events_url":"https://api.github.com/users/daattali/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rstudio/shiny/labels/needs-investigation","name":"needs-investigation","color":"b60205"},{"url":"https://api.github.com/repos/rstudio/shiny/labels/P1","name":"P1","color":"d93f0b"},{"url":"https://api.github.com/repos/rstudio/shiny/labels/targeted","name":"targeted","color":"e6e6e6"}],"state":"open","locked":false,"assignee":{"login":"jcheng5","id":129551,"avatar_url":"https://avatars.githubusercontent.com/u/129551?v=3","gravatar_id":"","url":"https://api.github.com/users/jcheng5","html_url":"https://github.com/jcheng5","followers_url":"https://api.github.com/users/jcheng5/followers","following_url":"https://api.github.com/users/jcheng5/following{/other_user}","gists_url":"https://api.github.com/users/jcheng5/gists{/gist_id}","starred_url":"https://api.github.com/users/jcheng5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcheng5/subscriptions","organizations_url":"https://api.github.com/users/jcheng5/orgs","repos_url":"https://api.github.com/users/jcheng5/repos","events_url":"https://api.github.com/users/jcheng5/events{/privacy}","received_events_url":"https://api.github.com/users/jcheng5/received_events","type":"User","site_admin":false},"assignees":[{"login":"jcheng5","id":129551,"avatar_url":"https://avatars.githubusercontent.com/u/129551?v=3","gravatar_id":"","url":"https://api.github.com/users/jcheng5","html_url":"https://github.com/jcheng5","followers_url":"https://api.github.com/users/jcheng5/followers","following_url":"https://api.github.com/users/jcheng5/following{/other_user}","gists_url":"https://api.github.com/users/jcheng5/gists{/gist_id}","starred_url":"https://api.github.com/users/jcheng5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcheng5/subscriptions","organizations_url":"https://api.github.com/users/jcheng5/orgs","repos_url":"https://api.github.com/users/jcheng5/repos","events_url":"https://api.github.com/users/jcheng5/events{/privacy}","received_events_url":"https://api.github.com/users/jcheng5/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-03-04T13:17:21Z","updated_at":"2016-08-10T21:17:12Z","closed_at":null,"body":"I'm not exactly sure how `eventReactive()` works internally so my diagnosis might not be correct.\r\n\r\nIt seems that when a reactive context tries to get the value of a reactive value that's defined with a `eventReactive()`, the first time it's called (ie. before the variable gets an initial value) a silent error is thrown with no text.\r\n\r\nExplanation:\r\n\r\nHere's a simple app that assigns the value of a button into the `foo` reactive using `eventReactive`, and there's also a textOutput that just displays static text\r\n\r\n```\r\nui <- fluidPage(\r\n  actionButton(\"btn\", \"Button\"),\r\n  textOutput(\"text\")\r\n)\r\n\r\nserver <- function(input, output, session) {\r\n  foo <- eventReactive(input$btn, input$btn)\r\n  \r\n  output$text <- renderText({\r\n    \"hello\"\r\n  })\r\n}\r\n\r\nshinyApp(ui = ui, server = server)\r\n```\r\n\r\nAs expected, the app shows a \"hello\" message.\r\n\r\nNow, add a `cat(foo())` just before returning \"hello\".  Now when you run the app, \"hello\" doesn't show up until after the button gets pressed, because before that the `cat(foo())` statement results in a \"silent\" error.  When I put a `browser()` there to inspect the value of `foo()`, I just got `Error:` without any text for the error.\r\n\r\nSorry this was not very well explained, I blame it on the fact that it's past 5am..."},"comment":{"url":"https://api.github.com/repos/rstudio/shiny/issues/comments/239007334","html_url":"https://github.com/rstudio/shiny/issues/1125#issuecomment-239007334","issue_url":"https://api.github.com/repos/rstudio/shiny/issues/1125","id":239007334,"user":{"login":"jcheng5","id":129551,"avatar_url":"https://avatars.githubusercontent.com/u/129551?v=3","gravatar_id":"","url":"https://api.github.com/users/jcheng5","html_url":"https://github.com/jcheng5","followers_url":"https://api.github.com/users/jcheng5/followers","following_url":"https://api.github.com/users/jcheng5/following{/other_user}","gists_url":"https://api.github.com/users/jcheng5/gists{/gist_id}","starred_url":"https://api.github.com/users/jcheng5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcheng5/subscriptions","organizations_url":"https://api.github.com/users/jcheng5/orgs","repos_url":"https://api.github.com/users/jcheng5/repos","events_url":"https://api.github.com/users/jcheng5/events{/privacy}","received_events_url":"https://api.github.com/users/jcheng5/received_events","type":"User","site_admin":false},"created_at":"2016-08-10T21:17:12Z","updated_at":"2016-08-10T21:17:12Z","body":"> It seems that when a reactive context tries to get the value of a reactive value that's defined with a eventReactive(), the first time it's called (ie. before the variable gets an initial value) a silent error is thrown with no text.\r\n\r\nThat's right, this is as intended. By default, if `input$btn` is `NULL` or an unclicked action button, the eventReactive is considered to be missing a prerequisite (`req(input$btn)`, more or less). This is what we want if the button says, e.g., \"Submit\" or \"Calculate\".\r\n\r\nIf that's not what you want, e.g. the button is something like \"Refresh\", \"Recalculate\", or \"Update\", then pass `ignoreNULL = FALSE` when calling `eventReactive()`.\r\n\r\n> it gets in some sort of loop that prints out Error: over and over again\r\n\r\nNow _that_ is unexpected..."}}
{"actor":{"display_login":"jcheng5"}}