Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

Stack traces from Reactor errors often show only operator internals. What tools does Reactor offer to find where in your code the failing pipeline was assembled?

Reactor offers four main tools. checkpoint("description") adds assembly information at one point in the chain at low cost, so the error names that point. Hooks.onOperatorDebug() captures an assembly stack trace for every operator, which is precise but expensive. ReactorDebugAgent from reactor-tools instruments our code at class load time to add assembly information with much lower runtime cost, and log() prints the signals, subscribe, request, onNext and onError, for one section of the chain.

Why this question is asked

The first time most developers see a Reactor error in production, the stack trace shows FluxMapFuseable, MonoFlatMap, FluxOnErrorResume and dozens of other operator classes, and not a single line of their own code. That is not a bug in Reactor; it is a consequence of how reactive code runs. Knowing the debugging tools turns a frustrating hunt into a quick fix, and interviewers ask about them because they reveal whether a candidate has actually debugged reactive code. In this answer, we will see why stack traces lose our code, then try each tool on the same failing pipeline and compare their cost.

1Why the Stack Trace Shows Only Operators

In imperative code, the stack trace at the moment of failure shows the chain of method calls that led there, which is the chain we wrote. In Reactor, we write the pipeline in one place, at assembly time, when operators are chained together, but it runs later, at execution time, often on another thread. When an error happens, the stack only contains the execution machinery: the scheduler thread, the operators passing signals to each other, and the lambda that threw. The method that assembled the pipeline returned long ago.

Java
Flux<Integer> prices() { // assembled here, in OrderService.java:31
return Flux.just("10", "20", "x")
.map(Integer::parseInt) // fails on "x" at execution time
.publishOn(Schedulers.parallel());
}
// java.lang.NumberFormatException: For input string: "x"
// at java.lang.Integer.parseInt(...)
// at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(...)
// at reactor.core.publisher.FluxArray$ArraySubscription.slowPath(...)
// ... no mention of OrderService.prices()

With one pipeline this is manageable, but in a real service a NumberFormatException could come from any of fifty map calls. What we need is assembly information: where in our code the failing operator was created. Each tool adds that information in a different way and at a different cost.

2Checkpoint(): Mark Points You Care About

checkpoint adds a marker to the chain. If an error passes through it, Reactor attaches a description of that marker to the exception as a suppressed exception, which appears in the printed stack trace.

Java
return Flux.just("10", "20", "x")
.map(Integer::parseInt)
.checkpoint("prices: parse supplier feed") // light: no stack trace captured
.publishOn(Schedulers.parallel());
// java.lang.NumberFormatException: For input string: "x"
// Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below:
// Assembly site of producer [reactor.core.publisher.FluxMapFuseable] is identified by light checkpoint [prices: parse supplier feed].

With only a description, checkpoint is very cheap, because it records a string rather than capturing a stack trace, so it is fine to leave in production code at important boundaries. The two-argument version, checkpoint(description, true), also captures the assembly stack trace at that point, at more cost. Calling checkpoint() with no arguments captures a stack trace too. The trade-off is that we only learn about the points we marked.

3Hooks.onOperatorDebug(): Assembly Traces Everywhere

The global debug hook makes every operator capture a stack trace when it is assembled. Called once at startup, before pipelines are created, it gives every error a full traceback of the assembly site.

Java
Hooks.onOperatorDebug(); // call once, before assembling pipelines
// Error has been observed at the following site(s):
// *__Flux.map ⇢ at com.shop.OrderService.prices(OrderService.java:33)
// |_ Flux.publishOn ⇢ at com.shop.OrderService.prices(OrderService.java:34)

The traceback now points straight at line 33 of our code. But there is a catch: capturing a stack trace for every operator, every time a pipeline is assembled, is very expensive. A service that assembles pipelines per request can lose a large part of its throughput. So the hook is a tool for local debugging and tests, not for production.

4ReactorDebugAgent: Assembly Info at Lower Cost

ReactorDebugAgent, in the io.projectreactor:reactor-tools module, gets similar information a cleverer way. It is a Java agent that, when classes are loaded, rewrites the bytecode of our methods that call Reactor operators, adding a checkpoint carrying the source file and line to each call site. No stack trace is captured at runtime; the location is written into the code itself.

Java
public static void main(String[] args) {
ReactorDebugAgent.init(); // before the application classes are loaded
SpringApplication.run(ShopApplication.class, args);
}
// Error has been observed at the following site(s):
// *__Flux.map ⇢ at com.shop.OrderService.prices(OrderService.java:33)
Comparing Reactor's debugging tools
ToolWhat it addsCostTypical use
checkpoint("desc")description at one pointvery lowproduction, key boundaries
checkpoint("desc", true)assembly stack trace at one pointmoderatesuspected hot spots
Hooks.onOperatorDebug()assembly trace for every operatorhighlocal debugging, tests
ReactorDebugAgentfile and line for every operatorlow at runtimeproduction and staging
log()signals of one sectionhigh if left oninvestigating behaviour

The runtime cost is low enough that many teams run it in production, though instrumentation slows startup somewhat and we should measure it. Spring Boot can initialise it automatically when reactor-tools is on the classpath, controlled by the spring.reactor.debug-agent.enabled property; check your version. ReactorDebugAgent.processExistingClasses() handles classes loaded before init.

5Log(): Watching the Signals

The other tools tell us where an error was assembled. log() answers a different question: what actually happened, in what order. It logs every signal passing through that point, which is ideal for problems that are not exceptions, such as a pipeline that completes empty, cancels early or requests fewer items than expected.

Java
Flux.just("10", "20", "x")
.map(Integer::parseInt)
.log("prices")
.subscribe(v -> {}, e -> {});
// [prices] onSubscribe(FluxMapFuseable.MapFuseableSubscriber)
// [prices] request(unbounded)
// [prices] onNext(10)
// [prices] onNext(20)
// [prices] onError(java.lang.NumberFormatException: For input string: "x")

log() can be given a category and a level, and an option to show which thread each signal runs on. It produces a line per signal, so it is for investigation in a test or staging, placed around the suspicious section, and removed afterwards.

6Follow-up questions

Which tool would you enable by default in production?

ReactorDebugAgent, if its startup cost is acceptable, because it gives file and line information for every operator at low runtime cost. On top of that, a few descriptive checkpoints at service boundaries make errors easy to read. Hooks.onOperatorDebug stays off in production.

Do these tools change the behaviour of the pipeline?

No. checkpoint and the agent only attach information to errors that pass through, and log only observes signals. The only effect is performance: the cost of capturing stack traces for onOperatorDebug and forced checkpoints, and the cost of logging for log().

Why does ReactorDebugAgent not see some of my operators?

It instruments classes as they load after init. Classes loaded before it, for example by early framework startup, need ReactorDebugAgent.processExistingClasses(). Also, it only instruments call sites in our bytecode, so operators assembled inside libraries are not annotated with our lines.

7Conclusion

In this answer, we saw why Reactor stack traces show operator internals: pipelines are assembled in one place and executed later, often on another thread. checkpoint adds a cheap description at chosen points, or a stack trace when forced; Hooks.onOperatorDebug captures assembly traces for every operator but is expensive; ReactorDebugAgent from reactor-tools instruments our call sites at load time to give file and line information at low runtime cost; and log() prints the signals of a section so we can see what actually happened.

What to say in the interviewAbout 90 seconds aloud

Open with

The reason the trace shows only operators is that a reactive pipeline is assembled in one place and executed later, often on another thread, so when it fails the stack contains the scheduler and the operators passing signals, not the method that built the chain.

Then, if they want more

Reactor gives us a few ways to get the assembly site back. checkpoint with a description marks a point in the chain, and if an error passes through it the description is attached to the exception. That is cheap, so I leave checkpoints at important boundaries even in production; with the force flag it also captures a stack trace there.

Hooks.onOperatorDebug makes every operator capture its assembly stack trace, which gives a perfect traceback but costs a lot of throughput, so I only use it locally or in tests.

ReactorDebugAgent from reactor-tools is the practical middle ground: it is a Java agent that rewrites our bytecode at class load, adding the file and line of each operator call, so we get similar information with little runtime cost. Spring Boot can initialise it when reactor-tools is on the classpath.

And log() is for a different question, what signals actually flowed: it logs subscribe, request, onNext, onError, onComplete and cancel for a section, which is how I debug things like a pipeline that completes empty.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Stack traces from Reactor errors often show only operator internals. What tools does...": https://scrivio-interview-library.netlify.app/spring-boot/reactive-testing-and-ops/fe3521f8de/