Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added debugging section #6743

Merged
merged 12 commits into from
May 22, 2024
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Beacon",
"skipFiles": ["<node_internals>/**"],
"smartStep": true,
"program": "${workspaceFolder}/packages/cli/bin/lodestar.js",
"args": ["beacon"],
jeluard marked this conversation as resolved.
Show resolved Hide resolved
"console": "integratedTerminal"
},
{
"type": "node",
"request": "launch",
"name": "Dev",
"skipFiles": ["<node_internals>/**"],
"smartStep": true,
"program": "${workspaceFolder}/packages/cli/bin/lodestar.js",
"args": ["dev"],
"console": "integratedTerminal"
}
]
}
17 changes: 17 additions & 0 deletions docs/pages/tools/debugging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Debugging
---

The simplest way to debug is to use the provided [launch.json](../../../.vscode/launch.json) `configurations`, made available in the `Run and Debug` section. Those configurations will start new `node` processes.
VS Code supports debugging Workers out of the box when using those configurations.

Remote `lodestar` processes can also be debugged by leveraging [node:inspector](https://nodejs.org/api/inspector.html). Adding `--inspect` to the node CLI (e.g. `NODE_OPTIONS=--inspect ./lodestar beacon`) allows to debug the main thread. To debug a specific `Worker`, follow those steps:

- remove `--inspect` from `node` CLI
- add following code to the `worker`

```js
import inspector from "node:inspector";
inspector.open();
inspector.waitForDebugger();
```
2 changes: 1 addition & 1 deletion docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const sidebars: SidebarsConfig = {
{
type: "category",
label: "Tools",
items: ["tools/flamegraphs", "tools/heap-dumps", "tools/core-dumps"],
items: ["tools/debugging", "tools/flamegraphs", "tools/heap-dumps", "tools/core-dumps"],
},
{
type: "category",
Expand Down
Loading