reitit

wevrem 2025-11-19T04:30:19.829089Z

I was checking some requests and responses and discovered that the :get handler on one of my api routes is getting called twice, but I can't figure out why or how or where. I'm only making the request from the front-end one time, and I don't see this behavior on other api calls (I checked a few). The network tab on the browser shows only one, successful, call. Has anyone ever experienced something like this? What did you do to troubleshoot?

opqdonut 2025-11-19T06:44:01.821219Z

Do you have some custom middleware? It could invoke the handler twice. I'd add some debug logging: dump the whole request and also the stacktrace (using something like (prn (Throwable.))). I'd be interested in figuring out if it's actually the same request and if the handlers get called by the same code path.

wevrem 2025-11-20T01:33:36.898489Z

That did the trick! I had never thought about (maybe never needed) a stack trace outside of throwing an exception, but that was just what I needed. I did indeed find some middleware that was behaving badly. All fixed now.

opqdonut 2025-11-20T08:47:46.512539Z

I'm glad! It's my favourite trick 🙂