mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-07 05:04:58 -05:00
Clean up correctly after API caller leaves
This commit is contained in:
@@ -83,6 +83,14 @@ apiHandler <- function(serverFuncSource) {
|
||||
)
|
||||
|
||||
shinysession <- ShinySession$new(ws)
|
||||
on.exit({
|
||||
try({
|
||||
# Clean up the session. Very important, so that observers
|
||||
# and such don't hang around, and to let memory get gc'd.
|
||||
shinysession$wsClosed()
|
||||
appsByToken$remove(shinysession$token)
|
||||
})
|
||||
}, add = TRUE)
|
||||
appsByToken$set(shinysession$token, shinysession)
|
||||
shinysession$setShowcase(.globals$showcaseDefault)
|
||||
|
||||
@@ -173,7 +181,13 @@ apiWsHandler <- function(serverFuncSource) {
|
||||
ws$close()
|
||||
})
|
||||
|
||||
# TODO: Handle ws$onClose()
|
||||
ws$onClose(function() {
|
||||
# Clean up the session. Very important, so that observers
|
||||
# and such don't hang around, and to let memory get gc'd.
|
||||
shinysession$wsClosed()
|
||||
appsByToken$remove(shinysession$token)
|
||||
})
|
||||
|
||||
# TODO: What to do on ws$onMessage?
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user