Skip to content

Commit 5fbf3dd

Browse files
committed
Wait for all proc to complete before throwing
1 parent 99a7542 commit 5fbf3dd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/kmono-build/src/k16/kmono/build.clj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,17 @@
160160
(.release semaphore)))))
161161
stage)]
162162

163-
(mapv deref op-procs)
163+
;; First deref everything, handling exceptions. This ensures that all
164+
;; procs finish before any exceptions are thrown.
165+
;;
166+
;; Once all procs are complete then throw if any were exceptional.
167+
(->> op-procs
168+
(mapv (fn [proc]
169+
(try
170+
(deref proc)
171+
(catch Exception ex ex))))
172+
(run! (fn [val]
173+
(when (instance? Exception val)
174+
(throw val)))))
175+
164176
(recur (rest stages))))))))

0 commit comments

Comments
 (0)