<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged debugging</title>
<link>https://ask.clojure.org/index.php/tag/debugging</link>
<description></description>
<item>
<title>Useful macro for output redirection (feature request)</title>
<link>https://ask.clojure.org/index.php/13246/useful-macro-for-output-redirection-feature-request</link>
<description>&lt;p&gt;I think it would be useful to add a macro which redirects the standard output to &lt;code&gt;*err*&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(with-err-out [&amp;amp; body]
  `(binding [*out* *err*]
     ~@body))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Macros</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13246/useful-macro-for-output-redirection-feature-request</guid>
<pubDate>Mon, 04 Sep 2023 14:24:24 +0000</pubDate>
</item>
<item>
<title>Strategies for diagnosing core.async code that is unexpectedly blocking the main thread?</title>
<link>https://ask.clojure.org/index.php/10190/strategies-diagnosing-async-unexpectedly-blocking-thread</link>
<description>&lt;p&gt;I'm new to core.async (and CSP more generally) and struggling to find good debugging strategies. In particular, I frequently fail to diagnosis which part of the code is infinitely blocking the main thread. I'll give a particular example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(deftest passing-test
  (let [c (async/to-chan! [2 1 0 5 4])]
    (is (= [2 1 0 5 4]
           (async/&amp;lt;!! (async/into [] c))))))


(deftest hanging-test
  (let [[e o] (-&amp;gt;&amp;gt; (async/to-chan! [2 1 0 5 4])
                   (async/split even?))]
    (is (= [2 0 4]
           (async/&amp;lt;!! (async/into [] e))))
    (is (= [1 5]
           (async/&amp;lt;!! (async/into [] o))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first test passes and does not block the main thread. The second test hangs forever. The only difference is the addition of &lt;code&gt;async/split&lt;/code&gt; to route even and odd integers to their respective channels.&lt;/p&gt;
&lt;p&gt;My specific questions are as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What explains the difference between the first and second tests with respect to blocking the main thread?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What are some strategies to debugging core.async code that is unexpectedly blocking the main thread?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is the best way to write unit tests for code that creates and manipulates channels? Is &lt;code&gt;(async/&amp;lt;!! (async/into [] o))&lt;/code&gt; a reasonable way to collect the values flowing through a channel into a collection?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10190/strategies-diagnosing-async-unexpectedly-blocking-thread</guid>
<pubDate>Sun, 14 Feb 2021 21:07:06 +0000</pubDate>
</item>
<item>
<title>is there a version of pr-str that emit full versions of qualified keywords in maps instead of short forms?</title>
<link>https://ask.clojure.org/index.php/9222/there-version-versions-qualified-keywords-instead-short-forms</link>
<description>&lt;p&gt; Something like &lt;code&gt;{:foo/bar 1}&lt;/code&gt; instead of &lt;code&gt;#:foo{:bar 1}&lt;/code&gt;&lt;br&gt;
I need to debug some edn and it's impossible to jump to the desired keywords if they're in the short forms.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9222/there-version-versions-qualified-keywords-instead-short-forms</guid>
<pubDate>Fri, 10 Apr 2020 07:54:25 +0000</pubDate>
</item>
<item>
<title>How do I get a full stack trace instead of &quot;... 12 more&quot;?</title>
<link>https://ask.clojure.org/index.php/8207/how-do-i-get-a-full-stack-trace-instead-of-12-more</link>
<description>&lt;p&gt;Using &lt;code&gt;lein run&lt;/code&gt;. There are no references to my *.clj file anywhere, so I don't know where this &lt;code&gt;java.lang.NullPointerException&lt;/code&gt; is coming from??&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Exception in thread &quot;main&quot; Syntax error compiling at (/tmp/form-init542794133375754487.clj:1:72).
    at clojure.lang.Compiler.load(Compiler.java:7647)
    at clojure.lang.Compiler.loadFile(Compiler.java:7573)
    at clojure.main$load_script.invokeStatic(main.clj:452)
    at clojure.main$init_opt.invokeStatic(main.clj:454)
    at clojure.main$init_opt.invoke(main.clj:454)
    at clojure.main$initialize.invokeStatic(main.clj:485)
    at clojure.main$null_opt.invokeStatic(main.clj:519)
    at clojure.main$null_opt.invoke(main.clj:516)
    at clojure.main$main.invokeStatic(main.clj:598)
    at clojure.main$main.doInvoke(main.clj:561)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:705)
    at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
    at xinova.model$reload_dbs.invokeStatic(model.clj:78)
    at xinova.model$reload_dbs.invoke(model.clj:78)
    at xinova.core$_main.invokeStatic(core.clj:18)
    at xinova.core$_main.doInvoke(core.clj:14)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:384)
    at user$eval140.invokeStatic(form-init542794133375754487.clj:1)
    at user$eval140.invoke(form-init542794133375754487.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:7176)
    at clojure.lang.Compiler.eval(Compiler.java:7166)
    at clojure.lang.Compiler.load(Compiler.java:7635)
    ... 12 more
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8207/how-do-i-get-a-full-stack-trace-instead-of-12-more</guid>
<pubDate>Fri, 26 Jul 2019 19:10:03 +0000</pubDate>
</item>
</channel>
</rss>