From fb7f4c6cbed20fbefd9f18919e30d7405df83597 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Jun 2022 11:55:42 +0200 Subject: [PATCH] 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 --- core/cli/packages.el | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/cli/packages.el b/core/cli/packages.el index 70bb77d28..7157b2d99 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -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 ()