Working hard on the Pedestal w/ Components docs and hitting some limits on what REPL reloading can accomplish so I have to rethink that.
I guess it's because clj-reload uses remove-ns (https://github.com/tonsky/clj-reload/blob/e88f60e0476866b68bb6c787ba4c69eea9d4dae3/src/clj_reload/core.clj#L283)
I wonder if using the ns-qualified symbol would work around the problem.
But doesn't it suggest that the long-running code that uses @#'symbol to enable simple at-the-REPL redefinitions is operating in the context of an orphaned clojure.lang.Namespace object, from which perspective not only the routing table found by @#'symbol but all its fn calls refer to pre-reload things. That is not good.
This is the type of thing that must've been Slacked to death and back in other channels. I hope you won't need to go too far out on a limb. At some point, it's a bug or "gotcha" in the reloader.
So it turns out, when using clj-reload (and possibly others) a Var instance may not be stable after reload. That is, the Var you have is from the old code and is "orphaned" and a new Var replaces it when the namespace is reloaded. This caused the old routing table to be "sticky" even after all other code reloaded. The fix was that I couldn't just (deref (var symbol)) but instead (deref (resolve symbol)). Of course, all of this is only when in development mode.
But I'll need to do some more tests for when the value passed to io.pedestal.connector/with-routes is an expression (a function call) and not a symbol.
Because, I think we'll see that the Fn object also holds orphaned Var instances.
Glad I went down this path, some big improvements here. I don't think the problems I saw would occur when using (require :reload my.namespace) which AFAIK just re-reads the content of my/namespace.clj) but doesn't create a new Namespace or change existing Vars mapped in the namespace. Again, AFAIK clj-reload does discard everything before reloading (which is good) but that can leave the orphaned references. And we hit all of this because we want this to work without stopping/restarting the Pedestal connector which (via either method) would see the latest code and use it.