rstudio / httpuv

HTTP and WebSocket server package for R
Other
227 stars 86 forks source link

service() fails to run inside later::with_temp_loop() #250

Open RLesur opened 4 years ago

RLesur commented 4 years ago

Originally posted in https://github.com/rstudio/pagedown/issues/150

This issue is related to later >= 1.0.0 which introduces private event loops.

The first observation is that httpuv uses only the global event loop even if startServer() is called inside later::with_temp_loop().

The problem is that service() does not execute the callbacks registered in the global loop when called inside later::with_temp_loop(). This comes from the fact that later::run_now() executes the callbacks registered in the current loop.

https://github.com/rstudio/httpuv/blob/57e1d715587acd16b566a910551d08a399d96656/R/httpuv.R#L588-L615

For now, the workaround is to use later::with_loop(later::global_loop(), httpuv::service()) instead of httpuv::service().