I am trying to write a Babashka script that downloads some files from a remote host using an SSH connection. For this, I use the ‘epiccastle.bbsh’ pod. The problem is that the script does not terminate, it gets stuck at the end of the main thread process. I thought it might be due to the thread pool used by Clojure agents and added the call to ‘(shutdown-agents)’. However, the script still gets stuck.

My babashka version is ‘v1.3.185’.

I have created a minimal version that reproduces the error:

(ns sample
  (:require [babashka.pods :as pods]))

(def bbsh-pod (pods/load-pod 'epiccastle/bbssh "0.5.0"))
(require '[pod.epiccastle.bbssh.core :as ssh])
(require '[pod.epiccastle.bbssh.scp :as scp])

(def user "user")
(def cert "/home/user/.ssh/id_rsa")

;; Main process
(let [session (ssh/ssh "localhost" {:username user :identity cert})
      opts {:session session}]
  (scp/scp-from "/etc/hosts" "remote-hosts" opts)
  (shutdown-agents)
  (println "shutdown"))

The script actually downloads the file, but does not terminate. Am I forgetting something? Is it a problem in Babashka? Could the problem be coming from the pod?

Asciinema Cast: https://asciinema.org/a/Loa2w96lXCzPE6LHtz4N4KGsm

Note: for the asciicast I added a ‘(System/exit 1)’ at the script end and it stills gets stuck.