Skip to content

Commit b735ff9

Browse files
committed
Initial notes
Updating notes
1 parent e280b73 commit b735ff9

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

diagnostics/index.md

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,60 @@
11
---
22
layout: default
33
title: Diagnostics
4+
author: donovan
5+
date: 1903-10-09
46
---
57

6-
Coming soon.
8+
Goals of this lesson:
79

8-
In the meantime, please see https://github.com/nodejs/diagnostics
10+
* Learn how to set up Node Debugger
11+
* Step through breakpoints using Repl
12+
* Inspecting in the Chrome debugger
13+
14+
Pre-requisites:
15+
16+
INTRO and expected outcomes
17+
18+
## Node.js Debugger
19+
20+
https://nodejs.org/api/debugger.html
21+
22+
## Debugging using Node.js with Chrome DevTools
23+
24+
https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.pmqejrn8q
25+
26+
Note: Chrome DevTools doesn't support debugging worker threads yet. ndb can be used to debug them.
27+
28+
### Diagnostic reports
29+
30+
Use Node's built-in `diagnostic report` feature:
31+
32+
https://nodejs.org/dist/latest-v11.x/docs/api/report.html
33+
34+
> With the report option enabled, diagnostic reports can be triggered on unhandled exceptions, fatal errors and user signals, in addition to triggering programmatically through API calls.
35+
36+
37+
38+
- A lot of services track everything going on in Node by monkey patching anything that is asynchronous, to keep track of processes over time
39+
- Introducing AsyncHooks from https://github.com/nodejs/diagnostics
40+
41+
* note: don't use console.log inside async_hooks methods as it is asynchronous and will cause infinite `init` calls, instead use `process._rawDebug(msg)`
42+
43+
44+
### Memory Leaks
45+
46+
// TODO: create example with a memory leak
47+
48+
```
49+
Monitor values from process.memoryUsage() over time.
50+
```
51+
52+
Make heap snapshots
53+
54+
https://www.npmjs.com/package/heapdump
55+
56+
Compare in chromium/chrome
57+
58+
// TODO: More on debugging memory leaks
59+
60+
## Summary

0 commit comments

Comments
 (0)