                     (build-compile)))
               )))))
 
-(defn do-idle [{:keys [extra-config-files] :as worker-state}]
+(defn maybe-recover-from-failure
+  [{:keys [package-json-file package-json-lastmod] :as worker-state}]
+  (if-not (and package-json-file package-json-lastmod)
+    worker-state
+    (let [newmod (.lastModified package-json-file)]
+      (if-not (> newmod package-json-lastmod)
+        worker-state
+        (do (log/debug ::package-json-modified)
+            (-> worker-state
+                (dissoc :package-json-file :package-json-lastmod)
+                (cond->
+                  (not (:build-state worker-state))
+                  (build-configure))
+                (build-compile)))))))
+
+(defn do-idle [{:keys [failure-data extra-config-files] :as worker-state}]
   (-> worker-state
       (cond->
         (seq extra-config-files)
-        (maybe-reload-config-files))))
+        (maybe-reload-config-files)
+
+        failure-data
+        (maybe-recover-from-failure)
+        )))

           :info (::build/build-info build-state)
           :reload-info (extract-reload-info build-state)})

        (assoc worker-state
          :build-state build-state
          ;; tracking added/modified namespaces since we finished compiling
          :namespaces-added #{}
          :namespaces-modified #{}
          :last-build-provides (-> build-state :sym->id keys set)
          :last-build-sources build-sources
          :last-build-macros build-macros))
      (catch Exception e
        (build-failure worker-state e)))))


            [shadow.build.warnings :as warnings]
            [shadow.build.data :as data]
            [shadow.build.resource :as rc]
            [shadow.build.log :as build-log]
            [clojure.java.io :as io])
  (:import [java.util UUID]))

(defn proc? [x]
