Skip to content

Commit

Permalink
Avoid way too many promise domains being activated
Browse files Browse the repository at this point in the history
Using `captureStackTraces` in wrapForContext is a bad idea, it
piles on a new domain every time a handler is bound.
  • Loading branch information
jcheng5 committed Nov 27, 2024
1 parent 501b012 commit d646bd8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/react.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ Context <- R6Class(

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)
captureStackTraces({
env <- .getReactiveEnvironment()
rLog$enter(.reactId, id, .reactType, .domain)
on.exit(rLog$exit(.reactId, id, .reactType, .domain), add = TRUE)
env$runWith(self, func)
})
})
})
},
Expand Down Expand Up @@ -223,9 +225,7 @@ wrapForContext <- function(func, ctx) {

function(...) {
.getReactiveEnvironment()$runWith(ctx, function() {
captureStackTraces(
func(...)
)
func(...)
})
}
}
Expand Down

0 comments on commit d646bd8

Please sign in to comment.