{"id":3773,"date":"2026-11-22T04:16:49","date_gmt":"2026-11-21T20:16:49","guid":{"rendered":"http:\/\/www.interalumina.com\/blog\/?p=3773"},"modified":"2026-11-22T04:16:49","modified_gmt":"2026-11-21T20:16:49","slug":"how-to-enable-debug-mode-in-project-reactor-43ab-1d273a","status":"publish","type":"post","link":"http:\/\/www.interalumina.com\/blog\/2026\/11\/22\/how-to-enable-debug-mode-in-project-reactor-43ab-1d273a\/","title":{"rendered":"How to enable debug mode in Project Reactor?"},"content":{"rendered":"<p>Hey folks, let\u2019s cut to the chase \u2013 if you\u2019re working with Project Reactor, you\u2019ve definitely been there: staring at a broken flux\/mono stack trace, and it\u2019s all just <code>onError<\/code> from some random operator with zero clue where it actually blew up. No line numbers, no context, just a vague message that\u2019s about as helpful as a dead smartphone in a blackout. <a href=\"https:\/\/www.gaokbio.com\/reactor\/\">Reactor<\/a><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.gaokbio.com\/uploads\/42097\/small\/dry-ingredient-mixer24aa0.jpg\"><\/p>\n<p>As a Reactor vendor, we\u2019ve seen this so many times that we built our whole platform around solving exactly this problem for teams that can\u2019t afford to waste hours debugging reactive streams. So today, I\u2019m gonna walk you through how to actually turn on debug mode in Project Reactor like a pro \u2013 no jargon overload, just stuff that works when you\u2019re knee-deep in a production incident. First off, let\u2019s get one thing straight: \u201cdebug mode\u201d isn\u2019t a single toggle. Reactor has a whole ecosystem of tools, and you gotta use the right ones for the job, not just hit a random switch and hope for the best.<\/p>\n<p>Let\u2019s start with the basics. The first and most common mistake we see devs make is just trying to slap <code>Hooks.onOperatorDebug()<\/code> somewhere in their app. Don\u2019t do that unless you know what you\u2019re getting into. Sure, it\u2019s simple \u2013 you call that method, and Reactor starts stacking assembly metadata into each signal. But here\u2019s the catch: that stuff is only retained for the life of the stream. If your app has tons of short-lived Fluxes, you\u2019re gonna leak memory. Not cool, especially when you\u2019re running on Kubernetes and every resource counts. Also, by default, <code>onOperatorDebug()<\/code> only gives you the assembly trace for operators that had an error. That\u2019s good, but what if you need to check a normal stream\u2019s flow?<\/p>\n<p>So let\u2019s talk about the real tools, starting with the built-in ones that come with every Reactor release. First up: <code>reactor.debug.mode<\/code> property. If you\u2019re using Spring Boot, this is super easy \u2013 just add <code>-Dreactor.debug.mode=advanced<\/code> to your JVM args, or set <code>reactor.debug.mode=advanced<\/code> in your <code>application.properties<\/code>. Wait, what\u2019s the difference between <code>simple<\/code> and <code>advanced<\/code> mode? Let\u2019s break it down: <code>simple<\/code> mode just adds operator assembly traces to error signals. <code>advanced<\/code>? It adds even more context \u2013 like the actual source line number where the operator was declared, and even the surrounding code lines if the compiler\u2019s setup right. But heads up: advanced mode adds a tiny bit of overhead, like 5-10% in our benchmarks, so we usually suggest turning it on only for staging or debug builds, not prod. Unless you\u2019re fine-tuning, but even then, most production teams stick to simple mode because it\u2019s light and gets the job done.<\/p>\n<p>Now, if you\u2019re not on Spring Boot (we\u2019ve got customers using raw Spring Boot, plain Java, even Quarkus and Micronaut), here\u2019s how to do it manually: either call <code>Hooks.onOperatorDebug()<\/code> at app startup, but only if you guard it properly. Wait, guard it how? Because if you call it multiple times, you\u2019ll overwrite hooks and cause weird, hard-to-reproduce bugs. So wrap it in a check: <code>if (System.getProperty(&quot;reactor.debug.mode&quot;) != null) Hooks.onOperatorDebug();<\/code> That way, it only runs when you actually set the property. Also, make sure this runs before you declare any Reactive Streams. If you call it after creating your first Flux, you won\u2019t get assembly traces for that stream. Trust me, we\u2019ve seen teams do this \u2013 waste an hour thinking debug mode is broken just because they placed the hook in the wrong spot.<\/p>\n<p>But wait, there\u2019s a newer tool in Reactor 3.5+ that\u2019s way better than <code>Hooks.onOperatorDebug()<\/code>: <code>DebugListener<\/code>. Oh right, this is a game-changer for teams that need more control. The old <code>onOperatorDebug()<\/code> was a global toggle, which meant every stream got debug info. What if you only want debug info for specific parts of your app? Like, your user-service flux is broken, but your payment-service flux is working fine \u2013 you don\u2019t need debug info for payments, that\u2019s just extra noise. With <code>DebugListener<\/code>, you can attach debug context only to the operators you care about. For example:<\/p>\n<pre><code class=\"language-java\">Flux.just(&quot;data&quot;)\n    .transformDeferred(Operators.debugMode())\n    .map(data -&gt; processData(data));\n<\/code><\/pre>\n<p>Wait, no, better example: if you have a custom operator, you can inject debug hooks selectively. Or, if you want to enable debug mode for a specific Flux, you can use <code>Flux.doOnEach()<\/code> with a debug listener, but actually, the <code>Operators.enableOnAssembly()<\/code> method (wait, no, that\u2019s <code>AssemblyUtils<\/code>) \u2013 yeah, <code>AssemblyUtils.enableOnAssembly()<\/code> lets you wrap individual streams. That\u2019s perfect for prod, because you don\u2019t have global overhead, and you only get debug info where you need it. As a vendor, we love this because it\u2019s flexible \u2013 you can turn debug on for a single endpoint, roll it back when you\u2019re done, no side effects.<\/p>\n<p>Now, let\u2019s talk about the hacks that actually work when stack traces are garbage. Like, when you get a stack trace that just says <code>reactor.core.Exceptions$ReactiveException: java.lang.NullPointerException<\/code> with no line numbers. That\u2019s where <code>DebugUtils.addAssumption()<\/code> or wait, no \u2013 the <code>reactor.debug.assembly.trace<\/code> flag? Wait, no, another one: Reactor has this thing called \u201ctraceback\u201d, which is the full assembly stack. If you set <code>-Dreactor.traceback=true<\/code>, Reactor will log the full path of how a stream was assembled, not just where the error happened. This is especially useful if your stack is coming from a nested operator. For example, if you have a Flux that calls another Flux, and the error is in the nested one, the traceback will show you the exact line in the parent Flux that called it. We had a customer last week who spent 3 hours trying to figure out why their <code>flatMap<\/code> was throwing NPE, and all they had was a generic error \u2013 adding <code>-Dreactor.traceback=true<\/code> fixed it in 2 minutes.<\/p>\n<p>But here\u2019s the thing: even with all these tools, most devs miss one huge step: bytecode instrumentation. Wait, that\u2019s not as scary as it sounds. Reactor has a bytecode inspector that can add debug info at compile time, or via a Java agent. The Java agent is super easy to use \u2013 just add <code>-javaagent:reactor-tools-agent.jar<\/code> to your JVM args. What does that do? It instruments Reactor\u2019s bytecode to inject assembly traces without you having to call any hooks. No more forgetting to add <code>Hooks<\/code> calls, no more global leaks, no more selective vs global mess. This is our go-to method for all our enterprise customers. Because the agent works transparently \u2013 it doesn\u2019t change your code, just adds the debug context you need. And the best part? You can enable it only for specific packages, so you don\u2019t get debug info for third-party Reactor libraries, which cleans up your stack traces.<\/p>\n<p>Now, let\u2019s cover the mistakes that will make debug mode useless, because we\u2019ve seen every single one. First, don\u2019t use debug mode in production unless you really have to. Even though the overhead is low, it\u2019s still extra processing, and if you have a busy prod app, every millisecond counts. We always tell our customers to use our monitoring tools (shameless plug, but it\u2019s true) to catch anomalies before they need debug mode, but when they do, use the agent in staging first to test it, then roll it to prod for the shortest time possible. Second, don\u2019t forget to compile with debug symbols. If you\u2019re using Maven, make sure <code>&lt;debug&gt;true&lt;\/debug&gt;<\/code> is in your compiler plugin config. If you\u2019re using Gradle, <code>debug { debuggable true }<\/code> in build types. Without debug symbols, even advanced mode won\u2019t give you line numbers \u2013 just class names and method names. Third, don\u2019t mix old Reactor versions with new tools. If you\u2019re on Reactor 3.4, <code>DebugListener<\/code> doesn\u2019t exist, so you have to use <code>Hooks<\/code> or the older agent. Make sure you\u2019re on the latest stable Reactor version \u2013 most of the bugs we fix in our platform are from devs running outdated Reactor with broken debug tools.<\/p>\n<p>Wait, let\u2019s test this with an example. Suppose you have a simple Flux that\u2019s broken:<\/p>\n<pre><code class=\"language-java\">Flux.just(1, 2, 0)\n    .map(i -&gt; 10 \/ i)\n    .subscribe(System.out::println);\n<\/code><\/pre>\n<p>If you run this normally, you\u2019ll get:<\/p>\n<pre><code>Exception in thread &quot;main&quot; java.lang.ArithmeticException: \/ by zero\n\tat com.example.MyApp.lambda$main$0(MyApp.java:10)\n\t...\n<\/code><\/pre>\n<p>Wait, that\u2019s actually okay here, but if your stream is nested:<\/p>\n<pre><code class=\"language-java\">Flux.range(1, 10)\n    .flatMap(i -&gt; Flux.just(i, 0).map(j -&gt; i \/ j))\n    .subscribe(System.out::println);\n<\/code><\/pre>\n<p>Now run that with <code>-Dreactor.debug.mode=simple<\/code>: you\u2019ll get an extra line in the stack trace:<\/p>\n<pre><code>Assembly trace from producer [FluxMap] :\n\t...\n\tat reactor.core.publisher.FluxMap.subscribe(FluxMap.java:...)\n<\/code><\/pre>\n<p>That tells you the operator that was assembled, which is the map inside the flatMap. Without debug mode, you\u2019d never know which map threw the error, because the stack would only show the inner lambda.<\/p>\n<p>Another example: using the Java agent. If you add <code>-javaagent:reactor-tools-agent.jar<\/code> and run the same nested stream, your stack trace will have the full assembly path: where the flatMap was declared, where the inner Flux.just was declared, all the way down to the line where the error happened. That\u2019s the stuff you need when you\u2019re tracing a complex stream with 10+ operators.<\/p>\n<p>Now, let\u2019s talk about when to use which tool, because that\u2019s the confusion we see most. If you\u2019re a solo dev working on a small app, just use <code>-Dreactor.debug.mode=simple<\/code> \u2013 it\u2019s easy, no setup, works right away. If you\u2019re on Spring Boot, use the property, no need to mess with JVM args (well, you still can, but Spring Boot abstracts it). If you\u2019re an enterprise team with microservices, use the Java agent \u2013 it\u2019s scalable, works across all your services, no code changes, easy to turn on\/off per service. If you just need debug info for one specific stream, use <code>AssemblyUtils.enableOnAssembly()<\/code> or <code>DebugListener<\/code> \u2013 it\u2019s selective, no global overhead, perfect for testing a new feature without cluttering all your logs.<\/p>\n<p>Wait, also, don\u2019t forget about Reactor\u2019s debug context. You can actually attach custom debug info to signals, like request IDs, user IDs, whatever. If you use <code>Mono.subscriberContext()<\/code> to add context, and then use <code>Hooks.onOperatorDebug()<\/code> or the agent, that context will show up in the debug traces. That\u2019s super useful for tracing errors across multiple services in a reactive ecosystem. For example, if you have a stream that goes from user-service to payment-service to order-service, adding the request ID to the subscriber context will let you find exactly which part of the flow failed, even across service boundaries.<\/p>\n<p>Now, let\u2019s get real \u2013 a lot of devs hate debug mode because of noisy logs. We get it. When you turn on debug mode, you might see a bunch of extra lines in your logs, but that\u2019s why we built our Reactor monitoring tool (yeah, the vendor part) that filters out the noise and only shows you the relevant debug info. So you don\u2019t have to sift through hundreds of lines to find the operator that threw an error. If you\u2019re tired of scrolling through stack traces for hours, our tool does that filtering automatically, and integrates seamlessly with all the debug modes we talked about.<\/p>\n<p>But even if you don\u2019t use our tool, you can still clean up logs. Use <code>Logger<\/code> to filter Reactor\u2019s debug logs. Reactor uses SLF4J, so you can set <code>logger.reactor.level=ERROR<\/code> in your logging config, and only see debug traces when there\u2019s an error. That way, you get the debug info you need when something breaks, but not when everything\u2019s working fine. That\u2019s a simple trick we learned early on \u2013 no more 100MB debug logs from a working app.<\/p>\n<p>Let\u2019s wrap this up with a quick checklist so you don\u2019t forget anything:<\/p>\n<ol>\n<li>Pick your tool based on your use case: solo dev = <code>reactor.debug.mode<\/code> property; microservices = Reactor agent; selective streams = <code>AssemblyUtils<\/code> \/ <code>DebugListener<\/code>.<\/li>\n<li>Always compile with debug symbols \u2013 no exceptions.<\/li>\n<li>Test debug mode in staging first, never run full advanced mode in prod for long.<\/li>\n<li>Filter Reactor logs to avoid noise \u2013 set Reactor\u2019s log level to ERROR normally.<\/li>\n<li>For complex cross-service flows, add subscriber context to track requests.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/www.gaokbio.com\/uploads\/42097\/small\/vacuum-emulsifying-mixer97cb3.jpg\"><\/p>\n<p>And before you go, if you\u2019re struggling with Reactor debug mode and wasting time on broken streams, we can help. Our team works with teams just like yours to fine-tune Reactor debug setup, optimize reactive flow performance, and eliminate those impossible-to-trace errors. Reach out to us to start a conversation, no pressure, just solving your reactive headaches.<\/p>\n<p><a href=\"https:\/\/www.gaokbio.com\/ethanol-extraction-machine\/lab-ultrasonic-extraction-machine\/\">Lab Ultrasonic Extraction Machine<\/a> Now, for references:<\/p>\n<ol>\n<li>Project Reactor Official Documentation \u2013 Debug Mode<\/li>\n<li>Reactor Tools Agent GitHub Repository<\/li>\n<li>Spring Boot Reactor Configuration Guide<\/li>\n<li>Reactor Core GitHub Repository \u2013 Hooks and DebugListener Sources<\/li>\n<\/ol>\n<hr>\n<p><a href=\"https:\/\/www.gaokbio.com\/\">Anyang Gaokang Medical Co., Ltd.<\/a><br \/>Anyang Gaokang Medical Co., Ltd. is one of the leading reactor manufacturers and suppliers in China. We warmly welcome you to buy high-grade reactor made in China here from our factory. All products are with high quality and competitive price.<br \/>Address: No.20, Guangming Road, Wenfeng District, Anyang, Henan, China<br \/>E-mail: Info@gaokangmedical-lab.com<br \/>WebSite: <a href=\"https:\/\/www.gaokbio.com\/\">https:\/\/www.gaokbio.com\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey folks, let\u2019s cut to the chase \u2013 if you\u2019re working with Project Reactor, you\u2019ve definitely &hellip; <a title=\"How to enable debug mode in Project Reactor?\" class=\"hm-read-more\" href=\"http:\/\/www.interalumina.com\/blog\/2026\/11\/22\/how-to-enable-debug-mode-in-project-reactor-43ab-1d273a\/\"><span class=\"screen-reader-text\">How to enable debug mode in Project Reactor?<\/span>Read more<\/a><\/p>\n","protected":false},"author":83,"featured_media":3773,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3736],"class_list":["post-3773","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-industry","tag-reactor-45ea-1d5ab0"],"_links":{"self":[{"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/posts\/3773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/users\/83"}],"replies":[{"embeddable":true,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/comments?post=3773"}],"version-history":[{"count":0,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/posts\/3773\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/posts\/3773"}],"wp:attachment":[{"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/media?parent=3773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/categories?post=3773"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.interalumina.com\/blog\/wp-json\/wp\/v2\/tags?post=3773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}