Repository navigation
Description
System details
RStudio Edition : Desktop and Server
RStudio Version : main (2026.12 daily), also reproduced on 2026.09
OS Version : macOS 27, Ubuntu 24.04
R Version : 4.6.1
Steps to reproduce the problem
In the Console, schedule a blocking loop on R's event loop rather than running it as console input:
later::later(function() shiny::runApp(shiny::shinyApp(shiny::fluidPage("hi"), function(input, output) NULL)), 1)Then try to do anything that needs the session: run another command, change a preference, click the Viewer's stop button, press Esc / the interrupt button, or reload the browser.
Describe the problem in detail
Once the callback starts, the IDE is deaf. The app runs (the Viewer shows it, console output arrives), but every request that must be handled by the session's main thread sits in the connection queue until the callback returns, which for runApp() is never:
- console input is echoed but never executes
- preference writes and every other RPC hang (the client's async-RPC acknowledgement arrives, the result never does)
- the Viewer stop button and the interrupt command do nothing: the interrupt RPC is itself queued, and even when handled it is dropped because interrupts are only armed while console input is executing
- a browser reload never gets past
client_init - there is no busy indicator, so nothing suggests R is busy and the "R is not responding" / Terminate dialog never engages
The only recovery is killing rsession.
A stack sample of the wedged main thread:
rConsoleRead -> http_methods::waitForMethod -> processEvents -> R_runHandlers
-> later async_input_handler -> execCallbacksForTopLevel -> <callback>
-> shiny::runApp -> later execCallbacks -> CallbackRegistry::wait
Why: while R is idle at the prompt, waitForMethod() is what dequeues requests, and it only does so between calls to processEvents() (which runs R's input handlers, including later's). If an input handler runs a long-lived callback, waitForMethod() never gets control back. The other drain, polledEventHandler() in SessionHttpMethods.cpp, only serves queued requests while console_input::executing() is true, and that flag is false here because, as far as the console is concerned, R is sitting at the prompt. The interrupt handler is gated on the same flag.
This is the same class as #17178 (help "Run examples" running runApp() on the event loop), which #17908 worked around for that one entry point. Any code path that schedules a blocking loop through later hits it: later::later(runApp), plumber/httpuv servers started from a callback, async packages whose callbacks block. It also took out a CI shard in #19226 when the Posit Assistant chose this launch style "to keep the console free".
Describe the behavior you expected
R code run from the idle event loop should be treated like any other busy R: the session keeps serving requests, interrupts stop it, and after a moment the console shows that R is busy.
Activity
queue dequeued console input ahead of idle handlers; restore the prom…
hold dequeued input while handlers run; restore the waiting read's ow…
discard held input on a queue clear; restore the prompt after discard…
e2e: wait for the server to queue console input before interrupting it
report busy again after a handler's own console read; fix the test he…
serve other requests before idle handlers; owe busy=false once report…
e2e: pin the buffered-read test's timing; assert the busy event off t…
hand queued input back ahead of an idle suspend; make the busy delay …
bound the busy-delay option
restore the top-level prompt flag after a handler's own console read
e2e: address round-2 review of the deaf-session diagnostics
e2e: fail fast, with an rsession stack dump, when the session stops s…
keep serving requests while r runs code from the idle event loop (#19237