Skip to content

Commit 5aaa6a3

Browse files
zalkyfogus
authored andcommitted
Fix TNS-6: fully remove ns from deps graph
The clojure.tools.namespace.dependency/remove-node fn removes a namespace's :dependencies set from the graph (outgoing edges), but does not remove that namespace from the :dependents set of other namespaces (ingoing edges). If a namespace is removed and one of its dependencies is changed at the same time, as commonly occurs when switching branches, then the removed namespace is still in the :dependents of the changed namespace when it is reloaded. As all the of the dependents of a changed namespace are also reloaded, this throws a missing namespace error. The resolution is to use clojure.tools.namespace.depedency/remove-all to remove both outgoing (:dependencies) and ingoing (:dependents) edges in the dependency graph. However, care must be taken when choosing the point of change, because clojure.tools.namespace.track/add relies on the partial removal behaviour of clojure.tools.namespace.track/remove-deps. It uses remove-deps to wipe the dependencies of a node, and cannot know how to re-insert dependents if lost. Therefore the point of change should be in clojure.tools.namespace.track/remove. Signed-off-by: Fogus <[email protected]>
1 parent daf82a1 commit 5aaa6a3

File tree

1 file changed

+1
-1
lines changed
  • src/main/clojure/clojure/tools/namespace

1 file changed

+1
-1
lines changed

src/main/clojure/clojure/tools/namespace/track.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
:or {load (), unload (), deps (dep/graph)}} tracker
9797
known (set (dep/nodes deps))
9898
removed-names (filter known names)
99-
new-deps (remove-deps deps removed-names)
99+
new-deps (reduce dep/remove-all deps removed-names)
100100
changed (affected-namespaces deps removed-names)]
101101
(assoc tracker
102102
::deps new-deps

0 commit comments

Comments
 (0)