Skip to content

Commit d54acbd

Browse files
authored
docs(learn): Migrate diagnostics user journey from guide to learn section (nodejs#6291)
* fix: redirect old guide links to new learn section - redirect old guide links to new learn section - fix the focus on click to the #filtering-out-nodejs-internal-functions * docs(learn): migrate diagnostics user journey to learn * doc(learn): add redirect changes * fix(learn): fix redirect url * doc(learn): move internal links to the nav and fix redirect * doc(learn): remove toc from files * docs(learn): change javascript snippets to js
1 parent 3511100 commit d54acbd

19 files changed

+98
-89
lines changed

i18n/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
"diagnostics": {
8888
"links": {
8989
"diagnostics": "Diagnostics",
90+
"userJourney": "User Journey",
91+
"memory": "Memory",
92+
"liveDebugging": "Live Debugging",
93+
"poorPerformance": "Poor Performance",
9094
"flameGraphs": "Flame Graphs"
9195
}
9296
}

navigation.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,22 @@
234234
"diagnostics": {
235235
"label": "components.navigation.learn.diagnostics.links.diagnostics",
236236
"items": {
237+
"userJourney": {
238+
"link": "/learn/diagnostics/user-journey",
239+
"label": "components.navigation.learn.diagnostics.links.userJourney"
240+
},
241+
"memory": {
242+
"link": "/learn/diagnostics/memory",
243+
"label": "components.navigation.learn.diagnostics.links.memory"
244+
},
245+
"liveDebugging": {
246+
"link": "/learn/diagnostics/live-debugging",
247+
"label": "components.navigation.learn.diagnostics.links.liveDebugging"
248+
},
249+
"poorPerformance": {
250+
"link": "/learn/diagnostics/poor-performance",
251+
"label": "components.navigation.learn.diagnostics.links.poorPerformance"
252+
},
237253
"flameGraphs": {
238254
"link": "/learn/diagnostics/flame-graphs",
239255
"label": "components.navigation.learn.diagnostics.links.flameGraphs"

pages/en/guides/backpressuring-in-streams.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pipes, sockets, and signals. In Node.js, we find a similar mechanism called
3636
part of the internal codebase utilizes that module. As a developer, you
3737
are more than encouraged to use them too!
3838

39-
```javascript
39+
```js
4040
const readline = require('readline');
4141

4242
// process.stdin and process.stdout are both instances of Streams.
@@ -67,7 +67,7 @@ While that will take a few minutes to complete, in another shell we may run
6767
a script that takes Node.js' module [`zlib`][], that wraps around another
6868
compression tool, [`gzip(1)`][].
6969

70-
```javascript
70+
```js
7171
const gzip = require('zlib').createGzip();
7272
const fs = require('fs');
7373

@@ -95,7 +95,7 @@ cleaning up and provide a callback when the pipeline is complete.
9595

9696
Here is an example of using pipeline:
9797

98-
```javascript
98+
```js
9999
const { pipeline } = require('stream');
100100
const fs = require('fs');
101101
const zlib = require('zlib');
@@ -120,7 +120,7 @@ pipeline(
120120

121121
You can also call [`promisify`][] on pipeline to use it with `async` / `await`:
122122

123-
```javascript
123+
```js
124124
const stream = require('stream');
125125
const fs = require('fs');
126126
const zlib = require('zlib');
@@ -156,7 +156,7 @@ trying to compress a file and write it to our hard disk, backpressure will
156156
occur because the write disk will not be able to keep up with the speed from
157157
the read.
158158

159-
```javascript
159+
```js
160160
// Secretly the stream is saying: "whoa, whoa! hang on, this is way too much!"
161161
// Data will begin to build up on the read-side of the data buffer as
162162
// `write` tries to keep up with the incoming data flow.
@@ -417,7 +417,7 @@ stream:
417417
In this case, your output from your [`Readable`][] stream will enter in the
418418
[`Transform`][] and will pipe into the [`Writable`][].
419419

420-
```javascript
420+
```js
421421
Readable.pipe(Transformable).pipe(Writable);
422422
```
423423

@@ -477,7 +477,7 @@ source. Otherwise, it will continue without pause.
477477

478478
Here is an example of bad practice using [`.push()`][]:
479479

480-
```javascript
480+
```js
481481
// This is problematic as it completely ignores return value from push
482482
// which may be a signal for backpressure from the destination stream!
483483
class MyReadable extends Readable {
@@ -495,7 +495,7 @@ backpressure. In this counter-example of good practice, the application's code
495495
forces data through whenever it is available (signaled by the
496496
[`'data'` event][]):
497497

498-
```javascript
498+
```js
499499
// This ignores the backpressure mechanisms Node.js has set in place,
500500
// and unconditionally pushes through data, regardless if the
501501
// destination stream is ready for it or not.
@@ -504,7 +504,7 @@ readable.on('data', data => writable.write(data));
504504

505505
Here's an example of using [`.push()`][] with a Readable stream.
506506

507-
```javascript
507+
```js
508508
const { Readable } = require('stream');
509509

510510
// Create a custom Readable stream
@@ -551,7 +551,7 @@ However, when we want to use a [`Writable`][] directly, we must respect the
551551

552552
<!-- eslint-disable indent -->
553553

554-
```javascript
554+
```js
555555
// This writable is invalid because of the async nature of JavaScript callbacks.
556556
// Without a return statement for each callback prior to the last,
557557
// there is a great chance multiple callbacks will be called.
@@ -573,7 +573,7 @@ There are also some things to look out for when implementing [`._writev()`][].
573573
The function is coupled with [`.cork()`][], but there is a common mistake when
574574
writing:
575575

576-
```javascript
576+
```js
577577
// Using .uncork() twice here makes two calls on the C++ layer, rendering the
578578
// cork/uncork technique useless.
579579
ws.cork();

pages/en/guides/diagnostics/index.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

pages/en/guides/dont-block-the-event-loop.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ If your callback takes a different number of steps depending on its arguments, t
116116

117117
Example 1: A constant-time callback.
118118

119-
```javascript
119+
```js
120120
app.get('/constant-time', (req, res) => {
121121
res.sendStatus(200);
122122
});
123123
```
124124

125125
Example 2: An `O(n)` callback. This callback will run quickly for small `n` and more slowly for large `n`.
126126

127-
```javascript
127+
```js
128128
app.get('/countToN', (req, res) => {
129129
let n = req.query.n;
130130

@@ -139,7 +139,7 @@ app.get('/countToN', (req, res) => {
139139

140140
Example 3: An `O(n^2)` callback. This callback will still run quickly for small `n`, but for large `n` it will run much more slowly than the previous `O(n)` example.
141141

142-
```javascript
142+
```js
143143
app.get('/countToN2', (req, res) => {
144144
let n = req.query.n;
145145

@@ -191,7 +191,7 @@ The exponential behavior is triggered when there is a mismatch but Node.js can't
191191

192192
Here is an example vulnerable regexp exposing its server to REDOS:
193193

194-
```javascript
194+
```js
195195
app.get('/redos-me', (req, res) => {
196196
let filePath = req.query.filePath;
197197

@@ -269,7 +269,7 @@ If your server manipulates JSON objects, particularly those from a client, you s
269269

270270
Example: JSON blocking. We create an object `obj` of size 2^21 and `JSON.stringify` it, run `indexOf` on the string, and then JSON.parse it. The `JSON.stringify`'d string is 50MB. It takes 0.7 seconds to stringify the object, 0.03 seconds to indexOf on the 50MB string, and 1.3 seconds to parse the string.
271271

272-
```javascript
272+
```js
273273
var obj = { a: 1 };
274274
var niter = 20;
275275

@@ -314,15 +314,15 @@ For a simple example, suppose you want to compute the average of the numbers `1`
314314

315315
Example 1: Un-partitioned average, costs `O(n)`
316316

317-
```javascript
317+
```js
318318
for (let i = 0; i < n; i++) sum += i;
319319
let avg = sum / n;
320320
console.log('avg: ' + avg);
321321
```
322322

323323
Example 2: Partitioned average, each of the `n` asynchronous steps costs `O(1)`.
324324

325-
```javascript
325+
```js
326326
function asyncAvg(n, avgCB) {
327327
// Save ongoing sum in JS closure.
328328
var sum = 0;

pages/en/guides/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ layout: docs.hbs
1010
## General
1111

1212
- [Easy profiling for Node.js Applications](/guides/simple-profiling/)
13-
- [Diagnostics - User Journey](/guides/diagnostics/)
1413
- [Security Best Practices](/guides/security/)
1514

1615
## Node.js core concepts

pages/en/guides/security/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ The [OpenSSF][] is leading several initiatives that can be very useful, especial
426426
[Slowloris]: https://en.wikipedia.org/wiki/Slowloris_(computer_security)
427427
[`http.Server`]: https://nodejs.org/api/http.html#class-httpserver
428428
[http docs]: https://nodejs.org/api/http.html
429-
[--inspect switch]: /guides/debugging-getting-started/
429+
[--inspect switch]: /learn/debugging-getting-started/
430430
[same-origin policy]: /guides/debugging-getting-started/
431431
[DNS Rebinding wiki]: https://en.wikipedia.org/wiki/DNS_rebinding
432432
[files property]: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#files

pages/en/guides/simple-profiling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To illustrate the use of the tick profiler, we will work with a simple Express
3030
application. Our application will have two handlers, one for adding new users to
3131
our system:
3232

33-
```javascript
33+
```js
3434
app.get('/newUser', (req, res) => {
3535
let username = req.query.username || '';
3636
const password = req.query.password || '';
@@ -52,7 +52,7 @@ app.get('/newUser', (req, res) => {
5252

5353
and another for validating user authentication attempts:
5454

55-
```javascript
55+
```js
5656
app.get('/auth', (req, res) => {
5757
let username = req.query.username || '';
5858
const password = req.query.password || '';
@@ -217,7 +217,7 @@ requests while computing a hash.
217217
To remedy this issue, you make a small modification to the above handlers to use
218218
the asynchronous version of the pbkdf2 function:
219219

220-
```javascript
220+
```js
221221
app.get('/auth', (req, res) => {
222222
let username = req.query.username || '';
223223
const password = req.query.password || '';
@@ -287,4 +287,4 @@ You may also find [how to create a flame graph][diagnostics flamegraph] helpful.
287287

288288
[profiler inside V8]: https://v8.dev/docs/profile
289289
[benefits of asynchronous programming]: https://nodesource.com/blog/why-asynchronous
290-
[diagnostics flamegraph]: /guides/diagnostics-flamegraph/
290+
[diagnostics flamegraph]: /learn/diagnostics/flame-graphs

pages/en/learn/diagnostics/flame-graphs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Now let's get to work.
3939
```
4040

4141
4. Disregard warnings unless they're saying you can't run perf due to missing packages; you may get some warnings about not being able to access kernel module samples which you're not after anyway.
42-
5. Run `perf script > perfs.out` to generate the data file you'll visualize in a moment. It's useful to [apply some cleanup](#filtering-out-node-js-internal-functions) for a more readable graph
42+
5. Run `perf script > perfs.out` to generate the data file you'll visualize in a moment. It's useful to [apply some cleanup](#filtering-out-nodejs-internal-functions) for a more readable graph
4343
6. Install stackvis if not yet installed `npm i -g stackvis`
4444
7. Run `stackvis perf < perfs.out > flamegraph.htm`
4545

pages/en/guides/diagnostics/live-debugging/index.md renamed to pages/en/learn/diagnostics/live-debugging/index.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
---
22
title: Live Debugging
3-
layout: docs.hbs
3+
layout: learn.hbs
44
---
55

66
# Live Debugging
77

8-
- [Live Debugging](#live-debugging)
9-
- [My application doesn’t behave as expected](#my-application-doesnt-behave-as-expected)
10-
- [Symptoms](#symptoms)
11-
- [Debugging](#debugging)
12-
138
In this document you can learn about how to live debug a Node.js process.
149

1510
## My application doesn’t behave as expected
@@ -28,4 +23,4 @@ application executes for a certain trigger like an incoming HTTP request. They
2823
may also want to step through the code and control the execution as well as
2924
inspect what values variables hold in memory.
3025

31-
- [Using Inspector](/guides/diagnostics/live-debugging/using-inspector)
26+
- [Using Inspector](/learn/diagnostics/live-debugging/using-inspector)

0 commit comments

Comments
 (0)