-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Describe the bug
A combination of this and (as an example) plumber::plumb() puts R into a state where it cannot be interrupted. httpgd alone and plumber alone do not trigger the non-interruptibility, it's the combination, and it's in R-4.3 and newer, R-4.2.2 does not have this problem.
First reported on emacs/ESS #1297, I have since confirmed that the bug is still present on the R console without an IDE.
To Reproduce
Demonstration of basic functionality with interruptibility:
while (TRUE) { Sys.sleep(1); message(format(Sys.time())); }
# 2025-02-11 09:18:17
# 2025-02-11 09:18:18
# 2025-02-11 09:18:19
# C-c C-c
httpgd::hgd()
# httpgd server running at:
# http://127.0.0.1:60946/live?token=6qZHAhGb
dev.list()
# unigd
# 2
while (TRUE) { Sys.sleep(1); message(format(Sys.time())); }
# 2025-02-11 09:18:23
# 2025-02-11 09:18:24
# C-c C-c
41+1
# [1] 42A simple plumber file:
#* @get /test
function(req, res, ...) { Sys.sleep(1); pi; }Using that plumber.R file in a fresh R session, this does NOT hang:
plumber::plumb("plumber.R")$run(port=9999)
# Running plumber API at http://127.0.0.1:9999
# Running swagger Docs at http://127.0.0.1:9999/__docs__/
# C-c C-c
41+1
# [1] 42Same plumber.R file, fresh R session, this DOES hang, every time:
Sys.getpid()
# [1] 38659
httpgd::hgd()
# httpgd server running at:
# http://127.0.0.1:60978/live?token=f5a6qLEH
dev.list()
# unigd
# 2
plumber::plumb("plumber.R")$run(port=9999)
# Running plumber API at http://127.0.0.1:9999
# Running swagger Docs at http://127.0.0.1:9999/__docs__/
# C-c C-c
# C-c C-c
# C-c C-c
### in a shell: `kill -HUP 38659`
# Process R:1 hangup: 1 at Tue Feb 11 09:21:24 2025Using just R consoles (no IDEs, no emacs, no nothin'),
At no time was the graphics device used.
Expected behavior
R remains interruptible.
Environment
- MacOS 15.3, R-4.4.3, httpgd-2.0.1 through -2.0.4, hangs every time
- Ubuntu 24.04, R-4.3.3, httpgd-2.0.4, plumber-1.2.2, hangs every time
- windows, R-4.2.3, httpgd-2.0.1 and -2.0.4, plumber-1.3.0, DOES NOT HANG (fresh install of packages, I tested both binary and compile-from-source)
- windows, R-4.4.3, httpgd-2.0.4, plumber-1.3.0, hangs every time
Additional context
I'm not convinced this is immune to changes in the R version or perhaps compiler/flags. The "win R-4.2.2" that doesn't hang perplexes me.
None of this is tested in RStudio (I don't have it installed, sorry).