Skip to content

Debugging Flux Services

When debugging a Flux Service, you gain the ability to inspect and change the flow of the service's execution. This includes adding breakpoints, stepping through states and transitions, examining the context, performing evaluations, and more. In this section, we will go over these features and learn how they can be used to debug a Flux Service.

Starting a Debug Session

To start a debug session, you need to run your Flux Service in debug mode. When a service is running in debug mode, you will be able to perform debug operations on that service. To do this:

  1. Open the Flux Service you want to debug.
  2. Right click on the canvas.
  3. Click Debug As > Flux Service.

Starting a debug session in Flux

  1. Open the Flux Service you want to debug.
  2. Right click any blank space on the canvas.
  3. Click Debug

Starting a debug session in Flux

Attaching the Debugger

If you have a Flux Service that is currently running and you want to perform debug operations on it, you can opt to use the Flux Debugger. The Flux Debugger has the ability to attach itself to a running Flux Service (whether already in a debug session or not) and when it is attached, a new debug session is created and started. To do this:

  1. Access the Integrate Service Manager.
  2. Right click the Flux Service you want to attach to.
  3. Click Attach Debugger.

You may now perform debug operations on that service.

Also, Coder Studio will prompt you to switch to Debug Perspective, simply click the Yes button when asked. This perspective contains all elements relevant for debugging services.

Attaching the Flux Debugger

Also, Coder Cloud will automatically open the Debug view for you. This view contains all elements relevant for debugging services.

Attaching the Flux Debugger

Toggling Breakpoints

Breakpoints are used as markers to suspend the execution of a service. In Flux, you can add them to the states either before or during debugging. To do this:

  1. Select one or more states.
  2. Right click then click Toggle Breakpoint.

Adding breakpoints in Flux

Adding breakpoints in Flux

Shortcut

You can use the shortcut Ctrl + Shift + B in Windows or ⌘⇧B on macOS to toggle a breakpoint when you have a state selected.

Breakpoints view

If you're in the Debug Perspective, you'll be able to see all of your breakpoints under the Breakpoints view.

Commands for Debugging

The Flux Debugger provides different execution operations that you can apply to a service that's being debugged:

  • Resume

    Resumes the debug execution until a breakpoint is hit or the service completes.

  • Pause

    Suspends the debug execution. If a state or transition is currently being executed, execution will be suspended on the next transition or state instead, respectively.

  • Terminate

    Stops the running service.

  • Step Into

    When used on a state, the current state will be invoked and then the execution stops before the transition. When used on a transition, the transition will be invoked and then the execution stops before the next state.

  • Step Over

    When used on a state, the current state and its transition will be invoked and then the execution stops before the next state. When used on a transition, the transition will be invoked then and then the execution stops before the next transition.

See the Shortcuts section for the corresponding keyboard shortcuts of these commands.

The Debug Perspective

The Flux Debug Perspective is similar to the Gloop Debug Perspective wherein the workspace is re-arranged so that it shows all views relevant when debugging.

The *Flux Debug Perspective*

The *Flux Debug Perspective*

When debugging a Flux Service, the user is given the option to use the Flux Debug Perspective. The prompt is displayed after inputs have been set and only when the service to be debugged has suspended.

Triggering the *Flux Debug Perspective*

Triggering the *Flux Debug Perspective*

Debug View

This view shows the debug execution stack of services that are currently and have been debugged.

The *Debug* view

The *Debug* view

Variables View

This view shows the current context of the service being debugged. The context is made available for display when the service's execution is suspended. It consists mainly of Flux Service inputs and outputs. If execution halts while on a state, then the state's input and output variables are added; if on a transition, then the transition's input and output variables are added.

The *Variables* view

The *Variables* view

Expressions View

This view allows you to run Groovy statements that use the variables available in the context; all you have to do is define and add the expressions.

In the example below, an expression was added to calculate the total price of all cart items with an additional price of 20 each:

Evaluating expressions via the *Expressions* view

Evaluating expressions via the *Expressions* view

Read-only evaluation

The evaluations made while debugging do not alter the values of the context.

Breakpoints View

This view shows all the breakpoints you have added via the Flux Service Editor. You could enable/disable the breakpoints by toggling the checkbox beside each entry.

The *Breakpoints* view

The *Breakpoints* view

Shortcuts

Command Description Shortcut
Debug Debugs the service previously run ⌘⇧ + F11
Toggle Breakpoint Adds or removes a breakpoint ⌘⇧B
Resume Resumes the debug execution F8
Terminate Stops the debug execution + F2
Step Into Executes the current state or transition and suspends the execution before entering the next state or transition F5
Step Over Executes the current state and transition and suspends the execution before entering the next state F6
Command Description Shortcut
Debug Debugs the service previously run + Alt + R
Toggle Breakpoint Adds or removes a breakpoint ⌘⇧B
Resume Resumes the debug execution F8
Pause Suspends the debug execution F8
Terminate Stops the debug execution + F2
Step Into Executes the current state or transition and suspends the execution before entering the next state or transition F5
Step Over Executes the current state and transition and suspends the execution before entering the next state F6