Hello everyone,
I've recently come across an error I've never seen in my eight years of shiny developing, which is getting me mad as it happens "sometimes". I mean, the same code with the same exact choices can or cannot work, it looks like shiny has a mood... and outside shiny, the snippet culpable for the breakage works well, with no problems at all. Unfortunately, I can't provide a reprex as the code is proprietary and quite complex to build an example.
Anyway, the snippet is a dissolving of a mixture of polygons terminating with deletions of holes.
bnd.szn()
is an sf object, a set of polygons, yb() is the list of codes to extract to build the final polygons
bnd.bcn <- bnd.szn() %>%
select(SZN) %>%
inner_join( yb() %>% select(SZN, id) ) %>%
select(id) %>%
rmapshaper::ms_dissolve('id') %>%
sfheaders::sf_remove_holes()
Below the log.
Thank you anyway
Luca
========================================================================
Listening on http://127.0.0.1:45425
Joining, by = "SZN"
Joining, by = "SZN"
Exception thrown during bootstrapping
*** caught segfault ***
address (nil), cause 'memory not mapped'
Traceback:
1: make_context(private$console)
2: reset()
3: (function() { eval <- function(src, serialize = FALSE) { evaluate_js(src, serialize = serialize) } validate <- function(src) { context_validate(join(src), private$context) } call <- function(fun, ..., auto_unbox = TRUE) { stopifnot(is.character(fun)) stopifnot(this$validate(c("fun=", fun))) jsargs <- list(...) if (!is.null(names(jsargs))) { stop("Named arguments are not supported in JavaScript.") } jsargs <- vapply(jsargs, function(x) { if (is.raw(x)) { raw_to_js(x) } else if (is.atomic(x) && inherits(x, "JS_EVAL")) { as.character(x) } else { toJSON(x, auto_unbox = auto_unbox) } }, character(1)) jsargs <- paste(jsargs, collapse = ",") src <- paste0("(", fun, ")(", jsargs, ");") get_json_output(evaluate_js(src, serialize = TRUE)) } source <- function(file) { if (is.character(file) && length(file) == 1 && grepl("^https?://", file)) { file <- curl(file, open = "r") on.exit(close(file)) } evaluate_js(readLines(file, encoding = "UTF-8", warn = FALSE)) } get <- function(name, ...) { stopifnot(is.character(name)) get_json_output(evaluate_js(name, serialize = TRUE), ...) } assign <- function(name, value, auto_unbox = TRUE, ...) { stopifnot(is.character(name)) obj <- if (is.raw(value)) { write_array_buffer(name, value, private$context) } else if (inherits(value, "JS_EVAL")) { invisible(evaluate_js(paste("var", name, "=", value))) } else { invisible(evaluate_js(paste("var", name, "=", toJSON(value, auto_unbox = auto_unbox, ...)))) } } reset <- function() { private$context <- make_context(private$console) private$created <- Sys.time() if (length(global)) { context_eval(paste("var", global, "= this;", collapse = "\n"), private$context) } if (isTRUE(typed_arrays)) { context_enable_typed_arrays(private$context) } invisible() } console <- function() { this$eval("") message("This is V8 version ", version(), ". Press ESC or CTRL+C to exit.") on.exit(message("Exiting V8 console.")) buffer <- character() has_history <- !inherits(try(savehistory(tempfile()), silent = T), "try-error") if (has_history) { savehistory() on.exit(loadhistory(), add = TRUE) histfile <- ".V8history" if (file.exists(histfile)) { loadhistory(histfile) } else { file.create(histfile) } } rc.options(custom.completer = function(env) { env$comps <- tab_complete(this, env$token) }) on.exit({ rc.options(custom.completer = NULL) }, add = TRUE) repeat { prompt <- ifelse(length(buffer), " ", "~ ") if (nchar(line <- readline(prompt))) { buffer <- c(buffer, line) } if (identical(buffer, "exit")) break if (length(buffer) && (this$validate(buffer) || !nchar(line))) { if (has_history) { write(buffer, histfile, append = TRUE) loadhistory(histfile) } tryCatch(cat(undefined_to_null(this$eval(buffer))), error = function(e) { message(e$message) }) buffer <- character() } } } reset() lockEnvironment(environment(), TRUE) structure(environment(), class = c("V8", "environment"))})()
4: V8::v8()
5: fun(libname, pkgname)
6: doTryCatch(return(expr), name, parentenv, handler)
7: tryCatchOne(expr, names, parentenv, handlers[[1L]])
8: tryCatchList(expr, classes, parentenv, handlers)
9: tryCatch(fun(libname, pkgname), error = identity)
10: runHook(".onLoad", env, package.lib, package)
11: loadNamespace(name)
12: getNamespace(ns)
13: asNamespace(ns)
14: getExportedValue(pkg, name)
15: geojsonio::geojson_list
16: force(x)
17: jsonlite::toJSON(unclass(geojsonio::geojson_list(x, type = "auto")), auto_unbox = TRUE, digits = 7, na = "null")
18: withCallingHandlers(expr, message = function(c) if (inherits(c, classes)) tryInvokeRestart("muffleMessage"))
19: suppressMessages(jsonlite::toJSON(unclass(geojsonio::geojson_list(x, type = "auto")), auto_unbox = TRUE, digits = 7, na = "null"))
20: geo_list_to_json(sf)
21: sf_to_GeoJSON(input, file = sys)
22: ms_sf(input = input, call = call, sys = sys)
23: dissolve_sf(input = input, field = field, sum_fields = sum_fields, copy_fields = copy_fields, weight = weight, snap = snap, sys = sys)
24: ms_dissolve.sf(., "id")
25: ms_dissolve(., "id")
26: remove_holes(obj, close)
27: sfheaders::sf_remove_holes(.)
28: bnd.szn() %>% select(SZN) %>% inner_join(yb() %>% select(SZN, id)) %>% select(id) %>% ms_dissolve("id") %>% sfheaders::sf_remove_holes()
29: eventReactiveValueFunc(...)
30: ..stacktraceon..(eventReactiveValueFunc(...))
31: valueFunc()
32: ..stacktraceon..(expr)
33: contextFunc()
34: env$runWith(self, func)
35: force(expr)
36: domain$wrapSync(expr)
37: promises::with_promise_domain(createVarPromiseDomain(.globals, "domain", domain), expr)
38: withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func)})
39: domain$wrapSync(expr)
40: promises::with_promise_domain(reactivePromiseDomain(), { withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func) })})
41: ctx$run(function() { ..stacktraceon..(expr)})
42: ..stacktraceoff..(ctx$run(function() { ..stacktraceon..(expr)}))
43: isolate(valueFunc())
44: func(v$value)
45: withVisible(func(v$value))
46: f(init, x[[i]])
47: Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) }}, list(...), result)
48: withCallingHandlers(expr, error = doCaptureStack)
49: domain$wrapSync(expr)
50: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
51: captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) }})
52: doTryCatch(return(expr), name, parentenv, handler)
53: tryCatchOne(expr, names, parentenv, handlers[[1L]])
54: tryCatchList(expr, classes, parentenv, handlers)
55: tryCatch({ captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) } })}, error = function(e) { if (!is.null(catch)) catch(e) else stop(e)}, finally = if (runFinally && !is.null(finally)) finally())
56: do()
57: hybrid_chain(eventFunc(), function(value) { if (ignoreInit && !initialized) { initialized <<- TRUE req(FALSE) } req(!ignoreNULL || !isNullEvent(value)) isolate(valueFunc())})
58: <reactive:eventReactive(input$btn_new_map)>
(...)
59: .func()
60: withVisible(.func())
61: withCallingHandlers({ .error <<- FALSE withVisible(.func())}, error = function(cond) { .value <<- cond .error <<- TRUE .visible <<- FALSE})
62: contextFunc()
63: env$runWith(self, func)
64: force(expr)
65: domain$wrapSync(expr)
66: promises::with_promise_domain(createVarPromiseDomain(.globals, "domain", domain), expr)
67: withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func)})
68: domain$wrapSync(expr)
69: promises::with_promise_domain(reactivePromiseDomain(), { withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func) })})
70: ctx$run(function() { result <- withCallingHandlers({ .error <<- FALSE withVisible(.func()) }, error = function(cond) { .value <<- cond .error <<- TRUE .visible <<- FALSE }) .value <<- result$value .visible <<- result$visible})
71: self$.updateValue()
72: ..stacktraceoff..(self$.updateValue())
73: mp()
74: eval(as.symbol(paste0("..", i)))
75: eval(as.symbol(paste0("..", i)))
76: isTruthy(item)
77: fun_(eval(as.symbol(paste0("..", i))))
78: dotloop(function(item) { if (!isTruthy(item)) { if (isTRUE(cancelOutput)) { cancelOutput() } else { reactiveStop(class = "validation") } }}, ...)
79: req(mp())
80: htmlwidgets::shinyRenderWidget
(...)
81: func()
82: force(expr)
83: withVisible(force(expr))
84: withCallingHandlers(expr, error = doCaptureStack)
85: domain$wrapSync(expr)
86: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
87: captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) }})
88: doTryCatch(return(expr), name, parentenv, handler)
89: tryCatchOne(expr, names, parentenv, handlers[[1L]])
90: tryCatchList(expr, classes, parentenv, handlers)
91: tryCatch({ captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) } })}, error = function(e) { if (!is.null(catch)) catch(e) else stop(e)}, finally = if (runFinally && !is.null(finally)) finally())
92: do()
93: hybrid_chain(func(), function(value) { transform(value, shinysession, name, ...)})
94: renderFunc(...)
95: output$outmap
(...)
96: ..stacktraceon..(output$outmap
(...))
97: orig(name = name, shinysession = self)
98: func()
99: withCallingHandlers(expr, error = doCaptureStack)
100: domain$wrapSync(expr)
101: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
102: captureStackTraces(expr)
103: withCallingHandlers(captureStackTraces(expr), error = function(e) { if (inherits(e, "shiny.silent.error")) return() handle <- getOption("shiny.error") if (is.function(handle)) handle()})
104: shinyCallingHandlers(func())
105: force(expr)
106: domain$wrapSync(expr)
107: promises::with_promise_domain(createVarPromiseDomain(private, "currentOutputName", name), expr)
108: private$withCurrentOutput(name, { shinyCallingHandlers(func())})
109: force(expr)
110: withVisible(force(expr))
111: withCallingHandlers(expr, error = doCaptureStack)
112: domain$wrapSync(expr)
113: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
114: captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) }})
115: doTryCatch(return(expr), name, parentenv, handler)
116: tryCatchOne(expr, names, parentenv, handlers[[1L]])
117: tryCatchList(expr, classes, parentenv, handlers)
118: tryCatch({ captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) } })}, error = function(e) { if (!is.null(catch)) catch(e) else stop(e)}, finally = if (runFinally && !is.null(finally)) finally())
119: do()
120: hybrid_chain({ private$withCurrentOutput(name, { shinyCallingHandlers(func()) })}, catch = function(cond) { if (inherits(cond, "shiny.custom.error")) { if (isTRUE(getOption("show.error.messages"))) printError(cond) structure(list(), class = "try-error", condition = cond) } else if (inherits(cond, "shiny.output.cancel")) { structure(list(), class = "cancel-output") } else if (inherits(cond, "shiny.silent.error")) { structure(list(), class = "try-error", condition = cond) } else { if (isTRUE(getOption("show.error.messages"))) printError(cond) if (getOption("shiny.sanitize.errors", FALSE)) { cond <- simpleError(paste("An error has occurred. Check your", "logs or contact the app author for", "clarification.")) } invisible(structure(list(), class = "try-error", condition = cond)) }})
121: force(expr)
122: withVisible(force(expr))
123: withCallingHandlers(expr, error = doCaptureStack)
124: domain$wrapSync(expr)
125: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
126: captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) }})
127: doTryCatch(return(expr), name, parentenv, handler)
128: tryCatchOne(expr, names, parentenv, handlers[[1L]])
129: tryCatchList(expr, classes, parentenv, handlers)
130: tryCatch({ captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) } })}, error = function(e) { if (!is.null(catch)) catch(e) else stop(e)}, finally = if (runFinally && !is.null(finally)) finally())
131: do()
132: hybrid_chain(hybrid_chain({ private$withCurrentOutput(name, { shinyCallingHandlers(func()) })}, catch = function(cond) { if (inherits(cond, "shiny.custom.error")) { if (isTRUE(getOption("show.error.messages"))) printError(cond) structure(list(), class = "try-error", condition = cond) } else if (inherits(cond, "shiny.output.cancel")) { structure(list(), class = "cancel-output") } else if (inherits(cond, "shiny.silent.error")) { structure(list(), class = "try-error", condition = cond) } else { if (isTRUE(getOption("show.error.messages"))) printError(cond) if (getOption("shiny.sanitize.errors", FALSE)) { cond <- simpleError(paste("An error has occurred. Check your", "logs or contact the app author for", "clarification.")) } invisible(structure(list(), class = "try-error", condition = cond)) }}), function(value) { self$requestFlush() private$sendMessage(recalculating = list(name = name, status = "recalculated")) if (inherits(value, "cancel-output")) { return() } private$invalidatedOutputErrors$remove(name) private$invalidatedOutputValues$remove(name) if (inherits(value, "try-error")) { cond <- attr(value, "condition") type <- setdiff(class(cond), c("simpleError", "error", "condition")) private$invalidatedOutputErrors$set(name, list(message = cond$message, call = utils::capture.output(print(cond$call)), type = if (length(type)) type)) } else private$invalidatedOutputValues$set(name, value)})
133: <observer:output$outmap>
(...)
134: contextFunc()
135: env$runWith(self, func)
136: force(expr)
137: domain$wrapSync(expr)
138: promises::with_promise_domain(createVarPromiseDomain(.globals, "domain", domain), expr)
139: withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func)})
140: domain$wrapSync(expr)
141: promises::with_promise_domain(reactivePromiseDomain(), { withReactiveDomain(.domain, { env <- .getReactiveEnvironment() rLog$enter(.reactId, id, .reactType, .domain) on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE) env$runWith(self, func) })})
142: ctx$run(.func)
143: run()
144: withCallingHandlers(expr, error = doCaptureStack)
145: domain$wrapSync(expr)
146: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
147: captureStackTraces(expr)
148: withCallingHandlers(captureStackTraces(expr), error = function(e) { if (inherits(e, "shiny.silent.error")) return() handle <- getOption("shiny.error") if (is.function(handle)) handle()})
149: shinyCallingHandlers(run())
150: force(expr)
151: withVisible(force(expr))
152: withCallingHandlers(expr, error = doCaptureStack)
153: domain$wrapSync(expr)
154: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
155: captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) }})
156: doTryCatch(return(expr), name, parentenv, handler)
157: tryCatchOne(expr, names, parentenv, handlers[[1L]])
158: tryCatchList(expr, classes, parentenv, handlers)
159: tryCatch({ captureStackTraces({ result <- withVisible(force(expr)) if (promises::is.promising(result$value)) { p <- promise_chain(valueWithVisible(result), ..., catch = catch, finally = finally) runFinally <- FALSE p } else { result <- Reduce(function(v, func) { if (v$visible) { withVisible(func(v$value)) } else { withVisible(func(invisible(v$value))) } }, list(...), result) valueWithVisible(result) } })}, error = function(e) { if (!is.null(catch)) catch(e) else stop(e)}, finally = if (runFinally && !is.null(finally)) finally())
160: do()
161: hybrid_chain({ if (!.destroyed) { shinyCallingHandlers(run()) }}, catch = function(e) { if (inherits(e, "shiny.silent.error")) { return() } printError(e) if (!is.null(.domain)) { .domain$unhandledError(e) }}, finally = .domain$decrementBusyCount)
162: flushCallback()
163: FUN(X[[i]], ...)
164: lapply(.flushCallbacks, function(flushCallback) { flushCallback()})
165: ctx$executeFlushCallbacks()
166: .getReactiveEnvironment()$flush()
167: flushReact()
168: serviceApp()
169: ..stacktracefloor..(serviceApp())
170: withCallingHandlers(expr, error = doCaptureStack)
171: domain$wrapSync(expr)
172: promises::with_promise_domain(createStackTracePromiseDomain(), expr)
173: captureStackTraces({ while (!.globals$stopped) { ..stacktracefloor..(serviceApp()) }})
174: ..stacktraceoff..(captureStackTraces({ while (!.globals$stopped) { ..stacktracefloor..(serviceApp()) }}))
175: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault