# Connect IoT Debug Code Task

**URL:** <https://community.criticalmanufacturing.com/t/connect-iot-debug-code-task/702>\
**Category:** Blog\
**Created:** [September 6, 2023, 12:00am UTC](https://community.criticalmanufacturing.com/t/connect-iot-debug-code-task/702 "2023-09-06T00:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Roque](https://yyz2.discourse-cdn.com/flex050/user_avatar/community.criticalmanufacturing.com/joao_roque/32/24_2.png) [@Joao\_Roque](https://community.criticalmanufacturing.com/u/Joao_Roque)\
**Post date:** [September 6, 2023, 12:00am UTC](https://community.criticalmanufacturing.com/t/connect-iot-debug-code-task/702/1 "2023-09-06T00:00:00Z")

</div>

This will be a how to, on debugging the code task.

## Topics

1. Overview
2. How To

## Overview

With the introduction of the code task, the need of customization has decreased substantially. Some of the complexity of customization has shifted to the code task. In software development, visibility and transparency on what is happening is essential, to better understand if the work fits the requirements and does not have undesirable side effects.

## How To

Using the visual studio code as administrator we will debug the code task. In the code task add a hook `debugger;` this hook will provide a breakpoint for the appended execution of the visual studio code debugger to stop.

 ![Adding Debugger Hook](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/ff15e3ce22df73b0c3e36aca2e7ca95d177daf90.png)

Start the `Automation Manager` and open visual studio code and select [`F1`](https://code.visualstudio.com/docs/getstarted/keybindings). After selecting `F1` a dropdown will appear, in this case we want to append to a node process, so select `Debug: Attach to Node Process`. It will show several node processes, the automation manager spawns at least 3 processes, one for the monitor, other for the driver and another for the controller. The code task is executed by the controller process, so that is the one we want to attach.

![Attach Debugger](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/9cfad72d29957209c4930f11e52eeca1338f6328.gif)

Now, whenever the code task is invoked it will stop in VS Code.

* * *

## Author

### Hello 👏 , my name is João Roque ✌️

I’ve been working for some years at Critical Manufacturing. I split my time working in the IoT Team and working with the project’s teams. You can visit me at [https://j-roque.com/](https://j-roque.com/) or check me at [LinkedIn](https://www.linkedin.com/in/j-roque/)

Skills: Connect IoT / DevOps

![João Roque](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/1048e9b7f9da629c9532c609c17f0c01471bc3b5.jpeg "IoT Developer Advocate")
_IoT Developer Advocate_

* * *
This is a companion discussion topic for the original entry at [https://devblog.criticalmanufacturing.com/blog/20230906\_iot\_debug\_code\_task/](https://devblog.criticalmanufacturing.com/blog/20230906_iot_debug_code_task/)
