Langsung ke konten
Skillpedia
API & server (backend)12k · #11570

node-inspect-debugger

Fungsinya

Skill ini mengajari agent cara menemukan bug di program Node.js dengan debugger bawaan dan alat terkait. Skill ini untuk pengembang yang menghadapi masalah sulit ditemukan, seperti hang, tes yang tidak stabil, atau masalah memori.

Kapan dipakai

  • ✓Saat program Node.js hang atau berperilaku aneh dan penyebabnya belum jelas.
  • ✓Saat sebuah tes tidak stabil dan Anda perlu berhenti tepat di titik kegagalannya.
  • ✓Saat Anda memerlukan snapshot memori atau profil CPU untuk menemukan bagian yang lambat atau bocor di aplikasi Node.js.

Link skill

https://github.com/EKKOLearnAI/ekko-studio/blob/main/packages/ekko-agent/skills/node-inspect-debugger/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/EKKOLearnAI/ekko-studio/blob/main/packages/ekko-agent/skills/node-inspect-debugger/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit →

Contoh permintaan ke AI

“Skrip Node.js saya kadang hang. Bantu saya menjedanya di baris yang tepat dan cari tahu penyebabnya.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent menjalankan program dengan inspector bawaan Node, menetapkan breakpoint, dan memeriksa nilai pada setiap titik berhenti. Untuk pemeriksaan berbasis skrip, agent juga bisa terhubung ke inspector melalui port lokal.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Node Inspect Debugger

Use when Node.js debugging requires hidden locals, async hangs, flaky tests, child processes, startup races, memory analysis, or CPU profiling.

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

Quick start

node inspect path/to/script.js
node --inspect-brk --import tsx path/to/script.ts
kill -SIGUSR1 <pid>
node inspect -p <pid>
curl -s http://127.0.0.1:9229/json/list | jq

For a test runner such as Vitest, debug one file with one worker and avoid worker pools while stepping.

Debugger REPL

  • Continue and 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: enter repl, evaluate locals, then press Ctrl+C to exit REPL mode.
  • Exit safely: use cont before quitting if the process should keep running; otherwise use kill.

Safe setup

  • Prefer 127.0.0.1 inspector binds. Do not expose --inspect=0.0.0.0 unless the network is isolated.
  • Use --enable-source-maps when TypeScript source breakpoints need it.
  • NODE_OPTIONS=--inspect-brk can propagate the inspector to child processes, but each process needs a unique port.
  • For a long-lived service, confirm the PID and /json/list target before attaching.

Programmatic CDP

Install temporary tooling outside the project unless it is already a dependency:

mkdir -p /tmp/cdp-tools
npm --prefix /tmp/cdp-tools install 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 a .cpuprofile, then open it in Chrome DevTools.
  • Heap: enable HeapProfiler, collect addHeapSnapshotChunk, call takeHeapSnapshot, then write a .heapsnapshot.

Pitfalls

  • --inspect does not pause; use --inspect-brk when startup code matters.
  • Port 9229 is the default; use --inspect=0 or a unique port for parallel targets.
  • If a breakpoint misses, confirm the path, source maps, and whether execution already passed the line.
  • A process that appears frozen after detach may still be paused in the debugger.
Pertanyaan umum

Apakah aman membiarkan debugger terbuka di jaringan?

Skill ini menyarankan untuk mengikat inspector ke 127.0.0.1 dan menghindari membukanya ke semua alamat jaringan.

Apakah ini bekerja dengan TypeScript?

Ya. Dengan source map, breakpoint dapat mengarah ke sumber TypeScript.

Bisakah ia men-debug proses anak?

Bisa, tetapi setiap proses membutuhkan port sendiri.

Detail

Deskripsi asli dari pembuat

Debug Node.js with node inspect, inspector attach, breakpoints, Chrome DevTools Protocol, heap snapshots, and CPU profiles.

repo: EKKOLearnAI/ekko-studio

Popularitas

Bintang GitHub
12k
Peringkat
#11570
Lisensi
—
Diperbarui
2/11/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa