Defer reactive cleanup on testServer() exit for the 1.14.0 release#4396
Draft
cpsievert wants to merge 3 commits into
Draft
Defer reactive cleanup on testServer() exit for the 1.14.0 release#4396cpsievert wants to merge 3 commits into
cpsievert wants to merge 3 commits into
Conversation
#4372 made a closing session destroy its bound reactives. testServer() closes its mock session on exit, so reactives created inside a module under test are destroyed as soon as the block returns. Several CRAN packages (blockr.core, blockr.dock, teal.slice) read such reactives after the testServer() block and broke with destroyedReactiveError. Comment out invokeDestroyCallbacks("") in MockShinySession$close() for the 1.14.0 release so the test harness reverts to pre-#4372 behavior. The real ShinySession still destroys on close, so app behavior is unchanged. A detailed note in the source explains how/when to re-enable after notifying the affected maintainers; the paired close-destroys tests are commented out with the same marker.
cpsievert
commented
Jun 1, 2026
cpsievert
commented
Jun 1, 2026
cpsievert
commented
Jun 1, 2026
| # paired tests in tests/testthat/test-destroy.R (search for this same | ||
| # marker) and tests/testthat/test-test-server.R. | ||
| # | ||
| # private$invokeDestroyCallbacks("") |
Collaborator
Author
There was a problem hiding this comment.
After #4395
Suggested change
| # private$invokeDestroyCallbacks("") | |
| # private$invokeDestroyCallbacks(allowRoot = TRUE) |
This was referenced Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
#4372makes a closing session destroy the reactives bound to it. BecausetestServer()closes its mock session on exit, reactives created inside a module under test are now torn down the moment thetestServer()block returns. Three CRAN reverse dependencies — blockr.core, blockr.dock, and teal.slice — read such reactives after thetestServer()block and now fail with"... its module session has been destroyed".To avoid breaking them in the 1.14.0 release, this temporarily reverts the test harness to its pre-
#4372behavior of leaving reactives intact on close.Scope and safety
The change comments out a single line —
invokeDestroyCallbacks("")— inMockShinySession$close(). The realShinySession(ShinySession$wsClosed()) still destroys reactives on close, so application behavior is unchanged; onlytestServer()/MockShinySessionis affected.This is deliberately temporary. A detailed note at the change site explains how and when to re-enable: once the affected maintainers have been notified to adapt their tests (create session-independent reactives with
withReactiveDomain(NULL, ...), or read/snapshot reactive state inside thetestServer()block), uncomment the line and the paired tests, which are commented out behind the same searchable marker intests/testthat/test-destroy.Randtests/testthat/test-test-server.R.Verification
A new test in
test-test-server.Rreproduces the failure (areactiveValuescreated inside a module is read aftertestServer()returns) and passes with the change. Both downstream failure shapes (returning a reactive from atestServer()helper; an external object holding a reactive created insidetestServer()) were confirmed fixed against this branch.