WarningLegacy version 6 documentation. View current documentation.

Debugging Finsemble

This tutorial provides an overview of techniques that you can use to quickly iterate with Finsemble. If you need targeted support, check out Troubleshooting.

Updating the Finsemble framework

If you encounter any bugs, please first make certain that you're using the latest version of Finsemble. You can verify this through package.json in ../node_modules/@finsemble/finsemble-core/package.json.

Updating the framework

To update the underlying Finsemble framework, run this commands from your local repository directory:

npm update @finsemble/finsemble-core

Updating the CLI

To update the Finsemble CLI, run this command from your local repository directory:

npm update -g @finsemble/finsemble-cli

Updating the entire package

Due to a bug with Gulp 4.0, npm update will not update Gulp correctly. If you need to update the entire package you need to follow this procedure:

rmdir /S node_modules
npm cache clean
npm install
npm install -g @finsemble/finsemble-cli

See also Upgrading Finsemble.

Using the Chromium Debugger

Finsemble runs on top of Chromium, which contains the same debugging tools that you are used to in Chrome. Here is how to access these tools:

  1. From the Google Chrome browser, enter "chrome://inspect" in the location bar.
  2. Click "Open Dedicated Devtools for Node."
  3. Click the "Connection" tab and add "localhost:9090" as a connection.
  4. A link to debug each Electron window will appear.
  5. After you complete these steps, you can press CTRL+SHIFT+I to pop up Chromium's debug tools in a new window.

An alternative debugging method is to open a browser and navigate to http://localhost:9090. Each window in your application is listed on that page. Click the window you want to debug and a Chromium Console will be launched for that window. There are some limitations (for example you can't evaluate code in the console in a remote session), but it largely acts as you would expect.

You can also force a component to spawn its console window along with itself by adding the appropriate prop to the component's config. More info in the config reference

Note Note: Only logger errors and warnings are written both to the Central Logger and Chrome Console. All the other logger functions (log, info, debug, verbose) are not captured by the Console.

Webpack

If you built your component with the Finsemble Webpack flow, when you open your component code with a debugger, you will see that it has been wrapped in a containing function. This provides automatic isolation of modules, automatic building of React modules, and so on. For the purpose of debugging, you can simply ignore this wrapper. Place your breakpoints inside your code and it should behave as expected.

You can modify the Webpack config files, if necessary, for your own component and service code (for example, if you are using a framework other than React). For more about the build process, see the Build Process tutorial.


Debugging inside the Finsemble Library

The Finsemble Library (FSBL.js) is automatically injected into your component's DOM. This way you can use Finsemble on any page without having to explicitly include the library. Chromium can be persnickety about debugging inside of such files (VM files). To get around this, you can manually include FSBL.js with a script tag:

<script src="/fin/FSBL.js"></script>

Finsemble's Electron Adapter log files

The Finsemble Electron Adapter log files can be found in AppData\Roaming\Electron\logs. These provide low level logging of container-level messages, which are mostly useful for debugging startup issues or issues with Finsemble's interactions with Electron. Most issues you'll encounter are more easily debugged in the Central Logger or in the javascript console for your component. However, if you think an issue is occuring at a lower-level, check the FEA log files.

Debugging a service

Debugging a service can be difficult because the service initialization happens before the Central Logger comes online. This issue can be eliminated by configuring Finsemble to open the service’s Chromium DevTools Console when the service is launched.

In the service’s configuration, add a property visible and set it to true. This can also be done to debug core Finsemble services (e.g., Config Service, Storage Service, etc.). The services’ configuration can be found in ../node_modules/@finsemble/finsemble-core/configs/core/services.json. You can either edit the config there or copy it to ..configs/application/services.json.

An example of this configuration for the Storage Service:

{
    "services": {
        "storageService": {
            "spawnAs": "window",
            "name": "storageService",
            "html": "$servicesRoot/storage/storage.html",
            "file": "$servicesRoot/storage/storageService.js",
            "category": "system",
            "visible": true
        }
    }
}

FSBL.debug - menus and the toolbar

FSBL.debug is a Boolean value. If set to true, menus will not hide on blur, and you will be able to reload the toolbar. Set the value anywhere inside of the menu or toolbar code.

Debugging the storage adapter

To debug the storage adapter, you configure visible property for the Storage Service to true. Start Finsemble and, when the service is visible, search for the Adapter’s file name (e.g., localStorageAdapter.js). Put breakpoints in the storage adapter where you need them. To debug initialization, you may need to set breakpoints and restart Finsemble.

If breakpoints are not hit in the Storage Adapter, set breakpoints for storage adapter methods (get, save, delete,keys, clearCache and empty) in the storage service; it has corresponding methods.


Debugging start-up and the system log

The System Manager Service controls Finsemble's start-up processes. The System Manager also provides a basic but always available system log for diagnostics. Whenever there is a start-up problem, it's best to first check the system log.

The system log provides:

  • The state of the start-up sequence
  • Catastrophic error messages
  • A copy of all user notifications since last start-up

You can access the system log in one of three ways:

  • The log will always be displayed when the manifest’s startup_app.autoShow value is set to true.
  • The log will be displayed only on startup error when the manifest config has finsemble.bootConfig.onErrorMakeSystemManagerVisible set to true.
  • The log can be manually displayed by selecting "System Log" in the Finsemble menu.

Depending on the case, more detailed diagnostic information can be found in the Chromium DevTools Console for the System Manager Service (see earlier in this topic).


Iterate quickly

Reload

It often isn't necessary to completely quit application components after making changes to them. The dev runner automatically watches for code changes and repackages on the fly. After you make a change and save your code, simply reload the component by right-clicking inside it and choosing "Reload." You can also press CTRL+ALT+R to reload the window that you're focused on.

Resetting your application

As you work on your test application, the application state will be saved to the activeWorkspace. If you need to start from scratch, you can delete this workspace. To clear your storage, you can use the Storage Client:

FSBL.Clients.StorageClient.clearCache(console.log);

You can also reset your app by using the icon on the tray.

Note Note: Be sure to quit your application without changing the location of any windows! You want to be sure that a new workspace isn't saved before you quit.

Deleting your cache

You can clear the browser cache for Finsemble. A separate cache folder exists for local development and each installed copy of Finsemble.

Note Note: This will also delete the storage for all of your Finsemble applications!

  1. Navigate to: C:\Users\AppData\Roaming\Electron for local development or C:\Users\AppData\Roaming<your desktop name> for an installed copy of a Finsemble desktop
  2. Delete the Cache folder

Note Note: AppData\Roaming\Electron\localStorage is the local storage, while "cache" is cached web pages and their assets. AppData\Roaming<your desktop name>/e2o/ceche/remote_modules is a cache of preload files.

Killing Finsemble

Hitting CTRL+C in your command prompt in which you built and ran Finsemble during development kills the application immediately. If you do this, Finsemble will not save changes to a named workspace and will try to restore the active workspace on restart.. In general, choosing Quit in the toolbar is a better option because it avoids state issues.


Common failure points (and their solutions)

npm run dev does nothing

If npm run dev does nothing and the runtime is hung, it may be because you have zombie processes. This can occur, for instance, if you kill off the dev runner before the application has properly started.

To get back to a good state, open your Windows Task Manager and kill any AssimilationMain.exe, node.exe, or electron.exe processes that are running. You should then be able to start the dev runner again. You may also delete your cache (see above) to solve this issue.

How can I inspect configuration settings if Finsemble doesn't come up?

- Case 1: The toolbar is up

If the toolbar is up, you launch the Central Logger to view the complete manifest containing Finsemble's configuration. First, bring up the Central Logger and ensure all service and component logging is visible by clicking on "Toggle All." Next, enter "processed manifest" into the "Filter Log" box (as opposed to the "Filter Client List" input box). The filtered log entry includes the complete run-time manifest with Finsemble's complete configuration under the FSBL object.

For this case, the data shown is after configuration has been fully processed on startup (e.g., macro's expanded, configuration files imported) but dynamic configuration changes haven't taken place yet. To see configuration after dynamic configuration changes, filter logs using "revised manifest" to get the revised configuration object.

- Case 2: The toolbar isn't fully up, but the Central Logger is up

In this scenario, Case 1 instructions might be useful; however that data may or may not exist depending on where start-up failed. Therefore, a third log filter, "initial manifest," is available to show the bootstrap configuration, which is the minimal initial configuration pulled from the manifest and Finsemble's core configuration in order to start the essential Finsemble services.

  • - Case 3: The toolbar isn't up and the Central Logger isn't up

If neither the toolbar nor the Central Logger are available, configuration can be seen using the Chromium Console through http://localhost:9090. If the Config Service exists, its console's output can be filtered using "processed manifest." However, that data may or may not exist depending on where start-up failed.

A more reliable option is to go into the "ServiceManager" window using http://localhost:9090. Click on the Central Logger entry and enter the command showConsole(). Filter on "initial manifest" to see the bootstrap configuration.

For all cases above, the Central Logger's log should also be inspected for configuration-related error messages (by turning off filtering and enabling only error messages).

Examining Finsemble-aware native registration

Follow these steps if you want to observe the registration process:

  1. Set up the breakpoints.

    • In the Central Logger, click the “Finsemble Support” button to make sure the relevant messages get logged.
    • In the Components and Services pane, click routerService to open Developer Tools.
    • Press Ctrl + Shift + F to open search and find the code for case "initialHandshake": It is located in the invokeHandler function. The function has multiple case statements. Put a breakpoint in the case "initialHandshake": case statement.
    • Next, in the Components and Services pane find assimilationService. Click it to open the Developer Tools for it.
    • Press Ctrl + Shift + F to open search and find the code there for RouterClient.addListener("Finsemble.Assimilation.register" It is in the createRouterEndpoints function. Put a breakpoint in the callback for the listener.
    • Click the “Clear Data'' button to remove the existing logged messages. This way, you only get messages for the launch of the native application
  2. Run your app and examine the checkpoints.

    • Launch your native app. It will hit the breakpoint for "initialHandshake".

    • Examine the message. It should look similar to this:

      {  
          "header": {
              "origin": "RouterClient.Finsemble WPF Demo-85-9739-Finsemble-Sales-Demo-Local",
              "originIncomingTransportInfo": {
                  "client": "RouterClient.Finsemble WPF Demo-85-9739-Finsemble-Sales-Demo-Local"
                  "transportID": "FinsembleTransport",
              },
              "type": "initialHandshake"
          }
      }
      
      • Remove the breakpoint. Otherwise "initialHandshake" will continue to be sent until there is a response.

      • Continue running the code, and you should hit the "Finsemble.Assimilation.register" breakpoint.

      • Examine the message. It should look similar to this:

        {
          "data": {
             "windowHandle": "300920",
             "windowName": "Finsemble WPF Demo-85-9739-Finsemble-Sales-Demo-Local"
             },
           "header": {
              "channel": "Finsemble.Assimilation.register",
              "incomingTransportInfo": {
                  "transportID": "SharedWorker", 
                  "port": 1 
           }, 
          "lastClient": "RouterClient.assimilationService" 
             "origin": "RouterClient.Finsemble WPF Demo-85-9739-Finsemble-Sales-Demo-Local",
          "originIncomingTransportInfo": {
             "client": "RouterClient.Finsemble WPF Demo-85-9739-Finsemble-Sales-Demo-Local", 
             "transportID": "FinsembleTransport"
             }, 
             "type": "transmit"
          },
        }
        

Note: For windowless components, the windowHandle is null.

  1. Continue running the code while monitoring the Central Logger for registerWindow. You should see these messages for each native app you launch:
  • "RouterClient: incoming query CHANNEL DockingService.registerWindow FROM RouterClient.assimilationService"
  • "registerWindow: starting registration"
  • "Assimilation.AssimilationWindowManager.registerWindow:"
  • "Docking: registerWindow. addWindow"
  • "RouterClient.query RESPONDER CHANNEL DockingService.registerWindow QUERY EVENT"
  • "RouterClient: outgoing query response CHANNEL DockingService.registerWindow RESPONSE DATA"
  • "query routed to responder RouterClient.assimilationService.????.DockingService.registerWindow" Service.????.DockingService.registerWindow"
  • "registerWindow: registration complete""queryResponse routed to queryID RouterClient.assimilationService.????.DockingService.registerWindow"
  • "RouterClient: incoming query response RESPONSE MESSAGE ... QUERY ID RouterClient.Assimilation Service.????.DockingService.registerWindow"

Note: Windowless components don’t generate these messages because they don’t have a window to register. If you search for the name of your component, you should see messages similar to:

11:37:37:470 COMPONENT LIFECYCLE: STATE CHANGE: created DotNetWindowless-26-4964-Finsemble-Seed-Local windowService

11:37:37:630 COMPONENT LIFECYCLE: STATE CHANGE: ready DotNetWindowless-26-4964-Finsemble-Seed-Local windowService

How to debug Finsemble and Electron main locally

You might sometimes want to add breakpoints to your code as you’re debugging it, so that you can collect more details at a specific point. You can do this in VS Code by adding this launch.json to your .vscode file. Here is the code:

{  
    "version": "0.2.0",
    "configurations": [
        { 
            "name": "Node Server",
            "type": "node",
            "request": "launch",
            "program": "${workspaceFolder}/server/server.js" 
        },
        { 
            "name": "Electron Main", 
            "type": "node",  
            "request": "launch", 
            "program": "${workspaceFolder}/node_modules/@chartiq/finsemble-electron-adapter/startup/devIndex.js", 
            "stopOnEntry": false,
            "args": ["ELECTRON_DEV=true"],
            "cwd": "${workspaceRoot}/node_modules/@chartiq/finsemble-electron-adapter", 
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", 
            "runtimeArgs": [  
                "--remote-debugging-port=9090 --inspect=5858", 
                "--manifest http://localhost:3375/configs/openfin/manifest-local.json" 
            ], 
            "env": {} 
        }, 
    ],  "compounds": [
        {     
            "name": "Node Server + Electron Main",   
            "configurations": ["Node Server", "Electron Main"]  
        } 
    ]
}

Launch.json

Here are the steps:

  1. Add launch.json to your .vscode folder in your finsemble-seed project OR Update the launch.json if you already have a launch.json with debug configuration. (Do this by merging your 'configurations' objects and adding the 'compounds' property from the attached launch.json).
  2. Add a breakpoint to \node_modules@chartiq\finsemble-electron-adapter\startup\devIndex.js.
  3. Run the 'Node Server + Electron Main' debug task.
  4. The debugger should halt at the relative break points.

See also

To zero in on a specific problem, see the Troubleshooting tutorial.

Check out the Central Logger, a great tool for diagnosing problems across multiple windows.