惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
博客园 - 司徒正美
博客园 - 【当耐特】
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
宝玉的分享
宝玉的分享
V
V2EX
S
SegmentFault 最新的问题
V
Visual Studio Blog
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
L
LangChain Blog
D
Docker
腾讯CDC

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat(skills): add debugger diagram and spike skills · ope...
steipete · 2026-05-17 · via Recent Commits to openclaw:main

@@ -0,0 +1,85 @@

1+

---

2+

name: node-inspect-debugger

3+

description: Debug Node.js with node inspect, --inspect, breakpoints, CDP, heap, and CPU profiles.

4+

metadata: { "openclaw": { "emoji": "🪲", "requires": { "bins": ["node"] } } }

5+

---

6+7+

# Node Inspect Debugger

8+9+

Use when logs are too weak for a Node.js bug: hidden locals, async hangs, flaky tests, child processes, startup races, memory growth, or CPU hot paths.

10+11+

Default to `node inspect` first. Use Chrome DevTools Protocol only when you need scripted breakpoints, automated state capture, heap snapshots, or CPU profiles.

12+13+

Quick start

14+15+

- Pause on entry: `node inspect path/to/script.js`

16+

- TypeScript: `node --inspect-brk --import tsx path/to/script.ts`

17+

- Existing PID: `kill -SIGUSR1 <pid>` then `node inspect -p <pid>`

18+

- Inspect target list: `curl -s http://127.0.0.1:9229/json/list | jq`

19+

- OpenClaw CLI path: `node --inspect-brk openclaw.mjs ...`

20+

- OpenClaw test path: `OPENCLAW_VITEST_MAX_WORKERS=1 node --inspect-brk scripts/run-vitest.mjs <file>`

21+22+

Debugger REPL

23+24+

- Continue/step: `cont`, `next`, `step`, `out`, `pause`

25+

- Breakpoints: `sb('file.js', 42)`, `sb(42)`, `sb('functionName')`, `breakpoints`, `cb('file.js', 42)`

26+

- Inspect: `bt`, `list(8)`, `watch('expr')`, `exec expr`

27+

- Current scope: `repl`, then evaluate locals directly; `Ctrl+C` exits repl mode.

28+

- Exit safely: `cont` before quitting if the process should continue; otherwise `kill`.

29+30+

OpenClaw tips

31+32+

- Prefer `127.0.0.1` inspector binds. Do not expose `--inspect=0.0.0.0` unless the network is isolated.

33+

- For Vitest, debug one file with one worker. Avoid worker pools while stepping.

34+

- For TS source breakpoints, use `--enable-source-maps` when useful; `node inspect` can still show emitted paths.

35+

- For child processes, `NODE_OPTIONS=--inspect-brk` can propagate the inspector, but each child needs its own port.

36+

- For long-lived gateway or dev processes, attach by PID after confirming the target with `/json/list`.

37+38+

Programmatic CDP

39+40+

Install tooling outside the repo unless the project already depends on it:

41+42+

```bash

43+

mkdir -p /tmp/cdp-tools

44+

npm --prefix /tmp/cdp-tools i chrome-remote-interface

45+

NODE_PATH=/tmp/cdp-tools/node_modules node /tmp/cdp-debug.cjs

46+

```

47+48+

Minimal driver:

49+50+

```js

51+

const CDP = require("chrome-remote-interface");

52+53+

(async () => {

54+

const client = await CDP({ port: 9229 });

55+

const { Debugger, Runtime } = client;

56+57+

Debugger.paused(async ({ callFrames, reason }) => {

58+

const top = callFrames[0];

59+

console.log("paused", reason, top.url, top.location.lineNumber + 1);

60+

const { result } = await Debugger.evaluateOnCallFrame({

61+

callFrameId: top.callFrameId,

62+

expression: "JSON.stringify({ pid: process.pid })",

63+

});

64+

console.log(result.value ?? result.description);

65+

await Debugger.resume();

66+

});

67+68+

await Runtime.enable();

69+

await Debugger.enable();

70+

await Debugger.setBreakpointByUrl({ urlRegex: ".*target\\.js$", lineNumber: 41 });

71+

await Runtime.runIfWaitingForDebugger();

72+

})();

73+

```

74+75+

Profiles

76+77+

- CPU: enable `Profiler`, `start`, wait, `stop`, write `/tmp/profile.cpuprofile`, open in Chrome DevTools.

78+

- Heap: enable `HeapProfiler`, collect `addHeapSnapshotChunk`, call `takeHeapSnapshot`, write `/tmp/heap.heapsnapshot`.

79+80+

Pitfalls

81+82+

- `--inspect` does not pause; use `--inspect-brk` when setup must happen before code runs.

83+

- Default port is `9229`; use `--inspect=0` or a unique port for parallel targets.

84+

- If a breakpoint misses, confirm file path, source map behavior, and whether execution already passed the line.

85+

- If the process appears frozen after detaching, it may still be paused in the debugger.