跳到正文
cccskills
免费在 GitHub 公开中文介绍

node-inspect-debugger

通过暂停Node.js执行、检查变量和跟踪执行路径,调查异步任务停滞、测试偶发失败等问题,也可分析内存持续增长和CPU负载的原因。

原文查看原文说明

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

AI 评分90分/ 100查看安装方法

适用场景

  • 调查异步任务停滞的原因
  • 调试偶发失败的测试
  • 排查启动和子进程问题
  • 分析内存增长和CPU负载

中文介绍

功能

暂停Node.js程序的执行,检查变量值并跟踪执行流程。首先使用node inspect,通过设置断点,也就是让程序暂停的位置,以及逐步执行操作来追查原因。必要时使用Chrome DevTools Protocol,以程序方式控制调试器,获取暂停时的状态、生成内存快照,并记录CPU执行时间。

适用场景

适合调查异步任务停滞、测试偶发失败,以及与启动时机有关的问题。也可用于检查子进程的行为、内存使用量持续增长,以及CPU负载集中的代码。调试时可以结合变量状态和执行路径检查问题。

使用示例

  • “在这个脚本启动时暂停,检查变量。”
  • “只调试一个包含偶发失败测试的文件。”
  • “采集CPU性能分析记录,我想查看执行耗时。”

注意事项

需要node。TypeScript执行示例使用tsx,程序控制示例使用chrome-remote-interface。连接地址原则上使用127.0.0.1,多个进程应分别分配端口。如果结束调试时仍让程序保持暂停,目标进程也会继续处于暂停状态。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

客观评估

AI 仅根据 SKILL.md 的内容,从 4 个方面进行了评估。星标数和热度不计入评估。

指令清晰度能否看出何时使用、做什么
A良好明确列出异步任务停滞等用途,并说明优先使用node inspect。
步骤具体性步骤、输入输出和示例是否具体
A良好提供启动命令、调试器操作、CDP代码示例和性能分析文件路径。
安全性发送数据、删除文件、执行命令等是否有说明
A良好要求确认连接目标、使用127.0.0.1,并在退出前恢复执行。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足说明需要node和tsx,并提供CDP工具安装示例,但未说明如何安装tsx。

总分按每项 A=25 分、B=15 分、C=5 分相加。 由 AI(OpenAI Codex)于 2026年10月19日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(1)

  • SKILL.md3.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Node Inspect Debugger

Use for Node.js debugging that needs inspector access: hidden locals, async hangs, flaky tests, child processes, startup races, memory growth, or CPU hot paths.

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

Quick start

  • Pause on entry: node inspect path/to/script.js
  • TypeScript: node --inspect-brk --import tsx path/to/script.ts
  • Existing PID: kill -SIGUSR1 <pid> then node inspect -p <pid>
  • Inspect target list: curl -s http://127.0.0.1:9229/json/list | jq
  • OpenClaw CLI path: node --inspect-brk openclaw.mjs ...
  • OpenClaw test path: OPENCLAW_VITEST_MAX_WORKERS=1 node --inspect-brk scripts/run-vitest.mjs <file>

Debugger REPL

  • Continue/step: cont, next, step, out, pause
  • Breakpoints: sb('file.js', 42), sb(42), sb('functionName'), breakpoints, cb('file.js', 42)
  • Inspect: bt, list(8), watch('expr'), exec expr
  • Current scope: repl, then evaluate locals directly; Ctrl+C exits repl mode.
  • Exit safely: cont before quitting if the process should continue; otherwise kill.

OpenClaw tips

  • Prefer 127.0.0.1 inspector binds. Do not expose --inspect=0.0.0.0 unless the network is isolated.
  • For Vitest, debug one file with one worker. Avoid worker pools while stepping.
  • For TS source breakpoints, use --enable-source-maps when useful; node inspect can still show emitted paths.
  • For child processes, NODE_OPTIONS=--inspect-brk can propagate the inspector, but each child needs its own port.
  • For long-lived gateway or dev processes, attach by PID after confirming the target with /json/list.

Programmatic CDP

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

mkdir -p /tmp/cdp-tools
npm --prefix /tmp/cdp-tools i chrome-remote-interface
NODE_PATH=/tmp/cdp-tools/node_modules node /tmp/cdp-debug.cjs

Minimal driver:

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

(async () => {
  const client = await CDP({ port: 9229 });
  const { Debugger, Runtime } = client;

  Debugger.paused(async ({ callFrames, reason }) => {
    const top = callFrames[0];
    console.log("paused", reason, top.url, top.location.lineNumber + 1);
    const { result } = await Debugger.evaluateOnCallFrame({
      callFrameId: top.callFrameId,
      expression: "JSON.stringify({ pid: process.pid })",
    });
    console.log(result.value ?? result.description);
    await Debugger.resume();
  });

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

Profiles

  • CPU: enable Profiler, start, wait, stop, write /tmp/profile.cpuprofile, open in Chrome DevTools.
  • Heap: enable HeapProfiler, collect addHeapSnapshotChunk, call takeHeapSnapshot, write /tmp/heap.heapsnapshot.

Pitfalls

  • --inspect does not pause; use --inspect-brk when setup must happen before code runs.
  • Default port is 9229; use --inspect=0 or a unique port for parallel targets.
  • If a breakpoint misses, confirm file path, source map behavior, and whether execution already passed the line.
  • If the process appears frozen after detaching, it may still be paused in the debugger.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

1password

免费有简介AI 评分 100分

检查1Password命令行工具的安装和认证,将已保存的密码或API密钥传入命令及配置。支持桌面应用集成、服务账号和交互式登录,并先验证访问权限。

  • 安装1Password命令行工具
  • 将API密钥传入命令
  • 在CI中使用服务账号认证
openclaw/openclaw39.2万2026年10月18日 更新

acp-router

免费有简介AI 评分 80分

将提交给OpenClaw的自然语言请求转交给Claude Code等外部编程智能体,通过ACP或acpx启动、继续会话,并保留对话上下文。

  • 在讨论串中启动Claude Code
  • 继续外部智能体的现有工作
  • 通过acpx直接传递指令
openclaw/openclaw39.2万2026年10月18日 更新

add-model-provider

免费有简介AI 评分 100分

为OpenClaw添加模型服务商,并通过实际回复验证连接。凭据以环境变量或文件引用的形式配置,同时验证设置并报告测试结果。

  • 为OpenClaw添加模型服务商
  • 通过引用配置认证凭据
  • 确认模型能返回实际回复
openclaw/openclaw39.2万2026年10月18日 更新

agent-transcript

免费有简介AI 评分 90分

将AI代理的工作日志整理为可附在GitHub拉取请求或议题中的记录,筛选相关内容、移除敏感信息,并支持预览及经单独授权后的发布。

  • 为拉取请求整理代理工作记录
  • 从本地日志提取相关请求和结果
  • 预览已移除敏感信息的记录
openclaw/openclaw39.2万2026年10月18日 更新

apple-notes

免费有简介AI 评分 100分

通过代理管理macOS上的Apple Notes笔记,支持创建、查看、搜索、编辑和删除,在文件夹之间移动笔记,并将选定笔记导出为HTML或Markdown。

  • 创建带标题的笔记
  • 按文件夹筛选或模糊搜索笔记
  • 编辑笔记并整理文件夹
openclaw/openclaw39.2万2026年10月18日 更新

apple-reminders

免费有简介AI 评分 70分

通过Mac查看、添加和编辑Apple Reminders中带截止时间的待办事项,管理列表并完成或删除任务,整理在iPhone或iPad上查看的个人任务。

  • 查看今天和已逾期的任务
  • 添加带截止日期的个人待办事项
  • 整理iPhone或iPad上的任务
openclaw/openclaw39.2万2026年10月18日 更新

查看 openclaw 的全部技能

报告此技能的问题