fix(cli): time out if native-comp hangs

Some packages (primarily vterm, evil-collection, and with-editor) end up
hanging their native compilation process. In vterm's case it's because
it invisibly prompts to compile its module then waits forever for user
input that'll never come. I haven't figured out why it happens for the
others though.

In any case, since the workaround is to simply kill these processes and
carry on, I added this timeout mechanism to do it for you (timing out
after 30s of no movement). A more elegant solution will have to wait
until the rewrite of our package manager.

Fix: #5592
This commit is contained in:
Henrik Lissner 2022-06-19 11:55:42 +02:00
parent 837f404fbc
commit fb7f4c6cbe
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -223,14 +223,25 @@ list remains lean."
(defun doom-packages--wait-for-native-compile-jobs ()
"Wait for all pending async native compilation jobs."
(cl-loop for pending = (doom-packages--native-compile-jobs)
with previous = 0
(cl-loop with previous = 0
with timeout = 30
with timer = 0
for pending = (doom-packages--native-compile-jobs)
while (not (zerop pending))
if (/= previous pending) do
(print! (start "\033[KNatively compiling %d files...\033[1A" pending))
(setq previous pending)
(setq previous pending
timer 0)
else do
(let ((inhibit-message t))
(if (> timer timeout)
(cl-loop for file-name being each hash-key of comp-async-compilations
for prc = (gethash file-name comp-async-compilations)
unless (process-live-p prc)
do (setq timer 0)
and do (print! (warn "Native compilation of %S timed out" (path file-name)))
and return (kill-process prc))
(cl-incf timer 0.1))
(sleep-for 0.1))))
(defun doom-packages--write-missing-eln-errors ()