nodejs-map 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -2
- package/dist/app/assets/LearnView-Cqz9Ux8w.js +3 -0
- package/dist/app/assets/LearnView-Cqz9Ux8w.js.map +1 -0
- package/dist/app/assets/LearnView-Nrw6YQU8.css +1 -0
- package/dist/app/assets/app.worker-DZKurLgd.js +8 -0
- package/dist/app/assets/app.worker-DZKurLgd.js.map +1 -0
- package/dist/app/assets/atlas.worker-DGHewGIv.js +2 -0
- package/dist/app/assets/atlas.worker-DGHewGIv.js.map +1 -0
- package/dist/app/assets/cm-BTWjV_Gb.js +13 -0
- package/dist/app/assets/cm-BTWjV_Gb.js.map +1 -0
- package/dist/app/assets/dist-B37Ex44M.js +2 -0
- package/dist/app/assets/dist-B37Ex44M.js.map +1 -0
- package/dist/app/assets/dist-Dv4HNg5q.js +2 -0
- package/dist/app/assets/dist-Dv4HNg5q.js.map +1 -0
- package/dist/app/assets/index-BRoted4h.css +1 -0
- package/dist/app/assets/index-eLItdROg.js +18 -0
- package/dist/app/assets/index-eLItdROg.js.map +1 -0
- package/dist/app/assets/map-CISW7_cc.css +1 -0
- package/dist/app/assets/map-mCCk9DTc.js +132 -0
- package/dist/app/assets/map-mCCk9DTc.js.map +1 -0
- package/dist/app/assets/sdf-label-font-1nAa0TP8.png +0 -0
- package/dist/app/config.json +5 -0
- package/dist/app/favicon.svg +1 -0
- package/dist/app/index.html +21 -0
- package/dist/atlas/v26.13.1/build-report.json +178 -0
- package/dist/atlas/v26.13.1/chunks/lib.bootstrap.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.core.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.crypto.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.devtools.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.events.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.modules.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.net.1.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.platform.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.process.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.streams.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.timers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.workers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/lib.zlib.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.callbacks.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.crypto.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.diag.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.inspector.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.loop.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.modules.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.napi.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.net.1.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.process.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.support.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/src.zlib.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.api.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.backends.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.fs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.loop.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.net.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.rest.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/uv.threadpool.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.api.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.asmjs.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.ast.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.base.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.baseline.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.bigint.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.builtins.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.codegen.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.codegen.riscv.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.common.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler-dispatcher.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.backend.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.compiler.turboshaft.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.d8.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.date.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.debug.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.deoptimizer.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.diagnostics.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.dumpling.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.execution.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.extensions.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.flags.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.fuzzilli.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.handles.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.heap.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.heap.cppgc.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.ic.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.init.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.inspector.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.interpreter.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.json.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.libplatform.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.libsampler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.logging.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.maglev.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.numbers.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.objects.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.parsing.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.profiler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.regexp.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.root.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.roots.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.runtime.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.sandbox.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.snapshot.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.strings.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.tasks.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.torque.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.tracing.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.trap-handler.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.utils.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.wasm.0.json +1 -0
- package/dist/atlas/v26.13.1/chunks/v8.zone.0.json +1 -0
- package/dist/atlas/v26.13.1/edges.json +1 -0
- package/dist/atlas/v26.13.1/files.json +1 -0
- package/dist/atlas/v26.13.1/index.json +1 -0
- package/dist/atlas/v26.13.1/search.json +1 -0
- package/dist/cli.js +6268 -0
- package/dist/examples.json +1 -0
- package/dist/learn/async-await.json +1 -0
- package/dist/learn/backpressure.json +1 -0
- package/dist/learn/big-picture.json +1 -0
- package/dist/learn/blocking-the-loop.json +1 -0
- package/dist/learn/breakpoints.json +1 -0
- package/dist/learn/call-stack.json +1 -0
- package/dist/learn/first-run.json +1 -0
- package/dist/learn/follow-readfile.json +1 -0
- package/dist/learn/four-threads-six-jobs.json +1 -0
- package/dist/learn/glossary.json +1 -0
- package/dist/learn/hiding-areas.json +1 -0
- package/dist/learn/http-one-request.json +1 -0
- package/dist/learn/http-two-requests.json +1 -0
- package/dist/learn/img/big-picture.webp +0 -0
- package/dist/learn/img/first-run-queues.webp +0 -0
- package/dist/learn/img/hide-restore-strip.webp +0 -0
- package/dist/learn/img/hide-view-menu.webp +0 -0
- package/dist/learn/img/map-call-path.webp +0 -0
- package/dist/learn/img/marks-in-a-run.webp +0 -0
- package/dist/learn/img/paused-at-breakpoint.webp +0 -0
- package/dist/learn/img/paused-in-node-fs.webp +0 -0
- package/dist/learn/img/playback-bar.webp +0 -0
- package/dist/learn/img/save-and-share.webp +0 -0
- package/dist/learn/img/tour-areas.webp +0 -0
- package/dist/learn/index.json +390 -0
- package/dist/learn/keep-alive.json +1 -0
- package/dist/learn/loop-phases.json +1 -0
- package/dist/learn/many-clients.json +1 -0
- package/dist/learn/microtasks-belong-to-v8.json +1 -0
- package/dist/learn/next-tick.json +1 -0
- package/dist/learn/observed-and-inferred.json +1 -0
- package/dist/learn/one-libuv-timer.json +1 -0
- package/dist/learn/order-and-esm.json +1 -0
- package/dist/learn/pipeline-errors.json +1 -0
- package/dist/learn/playback.json +1 -0
- package/dist/learn/pool-size.json +1 -0
- package/dist/learn/prerequisites.json +1 -0
- package/dist/learn/probe-build.json +1 -0
- package/dist/learn/promises-and-microtasks.json +1 -0
- package/dist/learn/reading-a-file.json +1 -0
- package/dist/learn/rec/async-await-chain.nmrec.gz +0 -0
- package/dist/learn/rec/backpressure.nmrec.gz +0 -0
- package/dist/learn/rec/beforeexit-and-exit.nmrec.gz +0 -0
- package/dist/learn/rec/block-loop.nmrec.gz +0 -0
- package/dist/learn/rec/dns-lookup-thread-pool.nmrec.gz +0 -0
- package/dist/learn/rec/esm-twist.nmrec.gz +0 -0
- package/dist/learn/rec/eventemitter-is-synchronous.nmrec.gz +0 -0
- package/dist/learn/rec/first-run.nmrec.gz +0 -0
- package/dist/learn/rec/fs-promises-await.nmrec.gz +0 -0
- package/dist/learn/rec/fs-sync-vs-async.nmrec.gz +0 -0
- package/dist/learn/rec/http-blocking-fixed.nmrec.gz +0 -0
- package/dist/learn/rec/http-blocking.nmrec.gz +0 -0
- package/dist/learn/rec/http-keep-alive.nmrec.gz +0 -0
- package/dist/learn/rec/http-roundtrip.nmrec.gz +0 -0
- package/dist/learn/rec/http-two-requests.nmrec.gz +0 -0
- package/dist/learn/rec/interval-and-clear.nmrec.gz +0 -0
- package/dist/learn/rec/nested-ticks-and-microtasks.nmrec.gz +0 -0
- package/dist/learn/rec/next-tick.nmrec.gz +0 -0
- package/dist/learn/rec/pbkdf2-six-jobs-four-threads.nmrec.gz +0 -0
- package/dist/learn/rec/phase-check.nmrec.gz +0 -0
- package/dist/learn/rec/phase-close.nmrec.gz +0 -0
- package/dist/learn/rec/phase-io.nmrec.gz +0 -0
- package/dist/learn/rec/pipeline-error.nmrec.gz +0 -0
- package/dist/learn/rec/pool-users.nmrec.gz +0 -0
- package/dist/learn/rec/pool-with-two-threads.nmrec.gz +0 -0
- package/dist/learn/rec/promise-microtasks.nmrec.gz +0 -0
- package/dist/learn/rec/readfile-thread-pool.nmrec.gz +0 -0
- package/dist/learn/rec/run-to-completion.nmrec.gz +0 -0
- package/dist/learn/rec/split-work.nmrec.gz +0 -0
- package/dist/learn/rec/stream-pipeline-file.nmrec.gz +0 -0
- package/dist/learn/rec/streams-memory.nmrec.gz +0 -0
- package/dist/learn/rec/tcp-many-clients.nmrec.gz +0 -0
- package/dist/learn/rec/tcp-round-trip.nmrec.gz +0 -0
- package/dist/learn/rec/tick-before-promise.nmrec.gz +0 -0
- package/dist/learn/rec/timeout-vs-immediate-io.nmrec.gz +0 -0
- package/dist/learn/rec/timeout-vs-immediate-main.nmrec.gz +0 -0
- package/dist/learn/rec/timer-lateness.nmrec.gz +0 -0
- package/dist/learn/rec/timer-vs-file-read.nmrec.gz +0 -0
- package/dist/learn/rec/timers-phase.nmrec.gz +0 -0
- package/dist/learn/rec/unref-timer.nmrec.gz +0 -0
- package/dist/learn/save-and-share.json +1 -0
- package/dist/learn/slow-handler.json +1 -0
- package/dist/learn/splitting-work.json +1 -0
- package/dist/learn/staying-alive.json +1 -0
- package/dist/learn/stepping-into-node.json +1 -0
- package/dist/learn/streams-basics.json +1 -0
- package/dist/learn/tcp-step-by-step.json +1 -0
- package/dist/learn/the-map.json +1 -0
- package/dist/learn/three-marks.json +1 -0
- package/dist/learn/timeout-vs-immediate.json +1 -0
- package/dist/learn/timers-are-not-now.json +1 -0
- package/dist/learn/tour.json +1 -0
- package/dist/learn/what-it-is.json +1 -0
- package/dist/learn/what-uses-the-pool.json +1 -0
- package/dist/lessons/async-await-chain.nmrec.gz +0 -0
- package/dist/lessons/beforeexit-and-exit.nmrec.gz +0 -0
- package/dist/lessons/dns-lookup-thread-pool.nmrec.gz +0 -0
- package/dist/lessons/esm-twist.nmrec.gz +0 -0
- package/dist/lessons/eventemitter-is-synchronous.nmrec.gz +0 -0
- package/dist/lessons/fs-promises-await.nmrec.gz +0 -0
- package/dist/lessons/fs-sync-vs-async.nmrec.gz +0 -0
- package/dist/lessons/index.json +621 -0
- package/dist/lessons/interval-and-clear.nmrec.gz +0 -0
- package/dist/lessons/nested-ticks-and-microtasks.nmrec.gz +0 -0
- package/dist/lessons/pbkdf2-six-jobs-four-threads.nmrec.gz +0 -0
- package/dist/lessons/pool-with-two-threads.nmrec.gz +0 -0
- package/dist/lessons/readfile-thread-pool.nmrec.gz +0 -0
- package/dist/lessons/tcp-round-trip.nmrec.gz +0 -0
- package/dist/lessons/tick-before-promise.nmrec.gz +0 -0
- package/dist/lessons/timeout-vs-immediate-io.nmrec.gz +0 -0
- package/dist/lessons/timeout-vs-immediate-main.nmrec.gz +0 -0
- package/dist/lessons/timer-vs-file-read.nmrec.gz +0 -0
- package/dist/lessons/timers-phase.nmrec.gz +0 -0
- package/dist/preload.cjs +507 -0
- package/package.json +25 -4
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lessons": [
|
|
3
|
+
{
|
|
4
|
+
"id": "tick-before-promise",
|
|
5
|
+
"title": "nextTick runs before promise callbacks (CommonJS)",
|
|
6
|
+
"summary": "A CommonJS script queues a nextTick, a promise reaction, a queueMicrotask callback and a 0 ms timeout. When the script ends Node empties the nextTick queue first, then the microtask queue; the timer waits for the event loop. Recorded on Windows; this order is the same on every system.",
|
|
7
|
+
"recording": "tick-before-promise.nmrec.gz",
|
|
8
|
+
"node": "26.13.1",
|
|
9
|
+
"steps": [
|
|
10
|
+
{
|
|
11
|
+
"index": 32,
|
|
12
|
+
"title": "The script has queued everything",
|
|
13
|
+
"text": "Open Queues: the nextTick queue holds two \"nextTick\" chips, the microtask queue a \"promise reaction\" and a \"queueMicrotask\" chip, and Timers a \"setTimeout 1 ms\" chip (a 0 ms timeout is stored as 1 ms). None of it has run yet. The first \"nextTick\" chip is not the program's: Node queued it while console.log wrote the first line, and it prints nothing."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"index": 38,
|
|
17
|
+
"title": "The nextTick queue goes first",
|
|
18
|
+
"text": "The script is done, and Node empties the nextTick queue before anything else. The Stack tab says this callback came from the nextTick queue; that is marked inferred, because nodejs-map worked it out from the item's type (TickObject)."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"index": 47,
|
|
22
|
+
"title": "Then the microtask queue",
|
|
23
|
+
"text": "Only when the nextTick queue is empty does V8 run the microtask queue. The promise reaction goes first because it was queued first; the queueMicrotask callback waits behind it in the same queue."
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"index": 65,
|
|
27
|
+
"title": "The timer comes last",
|
|
28
|
+
"text": "The 0 ms timeout runs only after both queues are empty, when the event loop reaches its timers phase. Node reported this phase itself (a RunTimers trace event), so the phase is marked observed."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "nested-ticks-and-microtasks",
|
|
34
|
+
"title": "Ticks and microtasks that queue each other",
|
|
35
|
+
"summary": "A nextTick that queues a promise and another tick, and a promise that queues a tick and a microtask. Each queue is emptied completely, including work added while it is being emptied, before Node moves on to the other one. Recorded on Windows; the order is the same on every system.",
|
|
36
|
+
"recording": "nested-ticks-and-microtasks.nmrec.gz",
|
|
37
|
+
"node": "26.13.1",
|
|
38
|
+
"steps": [
|
|
39
|
+
{
|
|
40
|
+
"index": 34,
|
|
41
|
+
"title": "Tick A runs and queues more",
|
|
42
|
+
"text": "Tick A is the first of the program's callbacks to run. While it runs it queues promise C and another tick, D: watch them appear in Queues."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"index": 48,
|
|
46
|
+
"title": "Tick D runs before any promise",
|
|
47
|
+
"text": "Tick D was added while the nextTick queue was being emptied, so it runs in the same round, before promise B, which has been waiting since the main script."
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"index": 57,
|
|
51
|
+
"title": "Now the microtask queue: B before C",
|
|
52
|
+
"text": "The nextTick queue is empty, so the microtasks run. Promise B was queued by the main script, so it is ahead of promise C; B queues tick E and microtask F."
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"index": 75,
|
|
56
|
+
"title": "F runs in the same round",
|
|
57
|
+
"text": "Microtask F was added while the microtask queue was running, so it runs in this same round, right after C. Tick E is still waiting in the nextTick queue."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"index": 82,
|
|
61
|
+
"title": "Back to the nextTick queue for E",
|
|
62
|
+
"text": "Only when the microtask queue is empty does Node go back to the nextTick queue and run tick E."
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"id": "esm-twist",
|
|
68
|
+
"title": "The ES module twist: promises before nextTick",
|
|
69
|
+
"summary": "The same nextTick and promise as in the CommonJS lesson, in an ES module: now the promise callback runs first. The module body itself runs inside a promise job, and V8 finishes the microtask queue before Node gets back to the nextTick queue. Recorded on Windows; the order is the same on every system.",
|
|
70
|
+
"recording": "esm-twist.nmrec.gz",
|
|
71
|
+
"node": "26.13.1",
|
|
72
|
+
"steps": [
|
|
73
|
+
{
|
|
74
|
+
"index": 59,
|
|
75
|
+
"title": "The module body is a microtask",
|
|
76
|
+
"text": "Look at the Stack tab while the module prints its first line: the top-level code is running inside a \"promise reaction\" callback (type PROMISE), not as a plain main script."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"index": 70,
|
|
80
|
+
"title": "Both are queued",
|
|
81
|
+
"text": "The module has queued a nextTick and a promise reaction. Queues shows two \"nextTick\" chips (the first is Node's own, from console.log) and one \"promise reaction\"."
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"index": 78,
|
|
85
|
+
"title": "The promise reaction runs first",
|
|
86
|
+
"text": "The module body was itself a microtask, and V8 keeps running microtasks until the queue is empty. So the promise reaction runs while the nextTick still waits."
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"index": 105,
|
|
90
|
+
"title": "Then the nextTick",
|
|
91
|
+
"text": "With the microtask queue empty, Node empties the nextTick queue; in the CommonJS lesson these two lines came out the other way round. The module made many more promises than Queues ever listed: a promise reaction is listed only from the moment its promise has settled until it runs, and every one listed in this recording ran."
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "async-await-chain",
|
|
97
|
+
"title": "An async/await chain: where each continuation runs",
|
|
98
|
+
"summary": "Three async functions call each other, then one awaits a 1 ms timer. Each async function runs synchronously up to its first await; every continuation after an await is a separate microtask. Recorded on Windows; the order is the same on every system.",
|
|
99
|
+
"recording": "async-await-chain.nmrec.gz",
|
|
100
|
+
"node": "26.13.1",
|
|
101
|
+
"steps": [
|
|
102
|
+
{
|
|
103
|
+
"index": 27,
|
|
104
|
+
"title": "a, b and c start synchronously",
|
|
105
|
+
"text": "Calling a() ran a, b and c one inside the other until c reached `await null`. All of this is still the main script: no callback is on the stack."
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"index": 39,
|
|
109
|
+
"title": "Only c can resume yet",
|
|
110
|
+
"text": "The main script is done. The microtask queue lists one \"promise reaction\": the rest of c, because `await null` can resume at once. b and a wait for promises that have not settled yet, so they are not listed (inferred, rule QP)."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"index": 45,
|
|
114
|
+
"title": "nextTick first",
|
|
115
|
+
"text": "As in every CommonJS script, the nextTick queue is emptied before any microtask runs."
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"index": 54,
|
|
119
|
+
"title": "c resumes in a microtask",
|
|
120
|
+
"text": "Now c continues after `await null`. On the Stack tab the code after an await is a \"promise reaction\" callback reached from the microtask queue."
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"index": 72,
|
|
124
|
+
"title": "Then b, then a",
|
|
125
|
+
"text": "b and then a resume, each in its own microtask, all in the same round of the microtask queue: no loop phase runs in between. Each one joined the queue only when the promise it awaited settled: b's when c returned, a's when b returned."
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"index": 97,
|
|
129
|
+
"title": "A timer resolves the last await",
|
|
130
|
+
"text": "`await sleep(1)` waits for a timer, the \"setTimeout 1 ms\" chip. The timer callback resolves the promise, and the rest of a() runs as a microtask right after it, still in the timers phase."
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"index": 107,
|
|
134
|
+
"title": "a() settles",
|
|
135
|
+
"text": "Finally the promise returned by a() settles, and the .then callback from the main script runs, again as a microtask."
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"id": "eventemitter-is-synchronous",
|
|
141
|
+
"title": "EventEmitter is synchronous",
|
|
142
|
+
"summary": "emit() calls every listener immediately, in the order they were added, and returns only when they have all run. Nothing goes through a queue or the event loop unless you defer it yourself, here with nextTick and setImmediate. Recorded on Windows; the order is the same on every system.",
|
|
143
|
+
"recording": "eventemitter-is-synchronous.nmrec.gz",
|
|
144
|
+
"node": "26.13.1",
|
|
145
|
+
"steps": [
|
|
146
|
+
{
|
|
147
|
+
"index": 21,
|
|
148
|
+
"title": "Listeners run inside emit()",
|
|
149
|
+
"text": "The first listener prints while the main script is still running: the main thread shows the main script, not a callback, and no queue was used."
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"index": 30,
|
|
153
|
+
"title": "emit() returns after all of them",
|
|
154
|
+
"text": "This line comes after all three listeners: emit() returned only when they had run."
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"index": 46,
|
|
158
|
+
"title": "Emitting from a nextTick",
|
|
159
|
+
"text": "The second emit happens inside a nextTick callback, and the listeners run inside that callback (see the Stack tab). The once listener is gone, so only listeners 1 and 3 print."
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"index": 66,
|
|
163
|
+
"title": "Emitting from an immediate",
|
|
164
|
+
"text": "The third emit runs inside the immediate callback, in the check phase of the event loop. Node reported this phase itself, so it is marked observed."
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "timers-phase",
|
|
170
|
+
"title": "Timers with different delays and the timers phase",
|
|
171
|
+
"summary": "Five timers with delays of 200, 100, 100, 1 and 0 ms. They run in order of due time, timers with the same delay run in the order they were created, and 0 ms is stored as 1 ms. Each group that is due together runs in one timers phase. Recorded on Windows; the order is the same on every system.",
|
|
172
|
+
"recording": "timers-phase.nmrec.gz",
|
|
173
|
+
"node": "26.13.1",
|
|
174
|
+
"steps": [
|
|
175
|
+
{
|
|
176
|
+
"index": 29,
|
|
177
|
+
"title": "Five timers wait",
|
|
178
|
+
"text": "The script has set five timers. Timers lists them soonest due first: two \"setTimeout 1 ms\" chips (D, and E, which asked for 0 ms), then two \"setTimeout 100 ms\" and one \"setTimeout 200 ms\"."
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"index": 38,
|
|
182
|
+
"title": "The first timers phase",
|
|
183
|
+
"text": "The loop enters its timers phase and runs every timer that is due. Node reported this phase itself, so it is marked observed."
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"index": 48,
|
|
187
|
+
"title": "D and E run in the same phase",
|
|
188
|
+
"text": "E was created after D with the same delay, so it runs right after D, in the same timers phase."
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"index": 66,
|
|
192
|
+
"title": "About 100 ms later: B and C",
|
|
193
|
+
"text": "Nothing is due for about 100 ms, so the loop waits. Then B and C are due together and run in creation order in one timers phase."
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"index": 93,
|
|
197
|
+
"title": "A runs last",
|
|
198
|
+
"text": "A was set first but has the longest delay, so it runs last: timers run by due time, not by the order of the setTimeout calls."
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "interval-and-clear",
|
|
204
|
+
"title": "setInterval and clearInterval",
|
|
205
|
+
"summary": "A 5 ms interval runs three times and then clears itself. One timer object is re-armed after every run until clearInterval takes it out; with nothing left to wait for, the process exits. Recorded on Windows; the order is the same on every system.",
|
|
206
|
+
"recording": "interval-and-clear.nmrec.gz",
|
|
207
|
+
"node": "26.13.1",
|
|
208
|
+
"steps": [
|
|
209
|
+
{
|
|
210
|
+
"index": 17,
|
|
211
|
+
"title": "One repeating timer",
|
|
212
|
+
"text": "setInterval created a single timer that repeats every 5 ms. Timers shows it waiting as \"setInterval 5 ms\"."
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"index": 34,
|
|
216
|
+
"title": "Re-armed after a run",
|
|
217
|
+
"text": "The first run has finished and the same timer is back in the timer list. Node did not report this: nodejs-map infers it because the timer repeats and was not cleared (rule QT2)."
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"index": 65,
|
|
221
|
+
"title": "The third run clears it",
|
|
222
|
+
"text": "The same timer runs a third time, in its own timers phase, and its callback calls clearInterval."
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"index": 77,
|
|
226
|
+
"title": "Taken out of the list",
|
|
227
|
+
"text": "clearInterval removed the timer, so Timers is empty and the loop has nothing left to wait for (inferred from the timer being destroyed before it ran again, rule QX)."
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"index": 82,
|
|
231
|
+
"title": "exit",
|
|
232
|
+
"text": "Node emits exit and the process ends. No callback is on the main thread: an exit listener is called directly, not as an async callback."
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"id": "timeout-vs-immediate-main",
|
|
238
|
+
"title": "setTimeout(0) vs setImmediate from the main script: a race",
|
|
239
|
+
"summary": "From the main script, a 0 ms timeout and an immediate race: which runs first depends on whether 1 ms has passed when the loop first looks at its timers. In this recording, made on Windows, the immediate ran first, as it did in 183 of 200 plain runs on this machine. The other order is normal too.",
|
|
240
|
+
"recording": "timeout-vs-immediate-main.nmrec.gz",
|
|
241
|
+
"node": "26.13.1",
|
|
242
|
+
"steps": [
|
|
243
|
+
{
|
|
244
|
+
"index": 19,
|
|
245
|
+
"title": "A timer and an immediate",
|
|
246
|
+
"text": "The script set a timeout of 0 ms, which Node stores as 1 ms, and an immediate. Queues shows a \"setTimeout 1 ms\" chip under Timers and a \"setImmediate\" chip under Immediates."
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"index": 25,
|
|
250
|
+
"title": "The check phase comes first this time",
|
|
251
|
+
"text": "The loop reached the check phase without running the timer: in this run the 1 ms had not passed when it looked at its timers. Node reported this check phase, so it is marked observed."
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"index": 39,
|
|
255
|
+
"title": "Then the timer",
|
|
256
|
+
"text": "The timer runs in the timers phase that follows. Run the program a few times on your own machine and you will sometimes see \"timeout 0\" first."
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"id": "readfile-thread-pool",
|
|
262
|
+
"title": "Reading a file: one trip through the thread pool",
|
|
263
|
+
"summary": "In Node 26, fs.readFile of a small file is a single thread pool job (ReadFileJob) that opens, reads and closes the file on a pool thread, then comes back once; only large files take several trips. Recorded on Windows, where finished requests run in the step right after poll.",
|
|
264
|
+
"recording": "readfile-thread-pool.nmrec.gz",
|
|
265
|
+
"node": "26.13.1",
|
|
266
|
+
"steps": [
|
|
267
|
+
{
|
|
268
|
+
"index": 25,
|
|
269
|
+
"title": "One job for the pool",
|
|
270
|
+
"text": "fs.readFile created a request, the \"fs.readFile\" chip, and handed one job to the thread pool. Open the Thread pool tab."
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
"index": 30,
|
|
274
|
+
"title": "A pool thread starts it",
|
|
275
|
+
"text": "A pool thread reported starting an \"fs.readfile\" job (observed); that it is this job is inferred (rule W2b). Thread reports reach nodejs-map late, so their place against main-thread events is approximate."
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"index": 34,
|
|
279
|
+
"title": "The thread is done",
|
|
280
|
+
"text": "The pool thread finished: open, read and close all happened there, in one job. The result now waits under \"Finished, waiting for delivery\" until the main thread is free and the loop picks it up."
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"index": 54,
|
|
284
|
+
"title": "The callback runs",
|
|
285
|
+
"text": "The loop delivers the result and the callback runs; the script's last line and the nextTick came earlier, as always. On Windows this happens in the pending step right after poll; Node did not report the phase, so it is marked inferred (rule P1w)."
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
"id": "timeout-vs-immediate-io",
|
|
291
|
+
"title": "setTimeout(0) vs setImmediate inside an I/O callback",
|
|
292
|
+
"summary": "Inside an I/O callback the immediate always runs before a 0 ms timeout, because the check phase comes right after the I/O step and the timers phase only after that. Recorded on Windows, where the I/O callback runs in the pending step right after poll; on Linux and macOS it runs inside poll. The order of the two lines is the same everywhere.",
|
|
293
|
+
"recording": "timeout-vs-immediate-io.nmrec.gz",
|
|
294
|
+
"node": "26.13.1",
|
|
295
|
+
"steps": [
|
|
296
|
+
{
|
|
297
|
+
"index": 30,
|
|
298
|
+
"title": "The I/O callback",
|
|
299
|
+
"text": "The \"fs.readFile\" request came back from the thread pool and its callback runs. The screen shows \"pending (after poll)\"; Node did not report this phase, nodejs-map worked it out from the callback's type (rule P1w), so it is marked inferred."
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"index": 41,
|
|
303
|
+
"title": "A timer and an immediate from inside it",
|
|
304
|
+
"text": "Inside the callback the program sets a 0 ms timeout and an immediate: Queues shows \"setTimeout 1 ms\" under Timers and \"setImmediate\" under Immediates."
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"index": 49,
|
|
308
|
+
"title": "Check comes next: the immediate",
|
|
309
|
+
"text": "After the I/O step the loop goes on to the check phase, so the immediate runs. This phase was reported by Node and is marked observed."
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"index": 62,
|
|
313
|
+
"title": "Then the timers phase",
|
|
314
|
+
"text": "Only after the check phase does the loop reach its timers phase and run the timeout. From an I/O callback this order does not change between runs."
|
|
315
|
+
}
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"id": "timer-vs-file-read",
|
|
320
|
+
"title": "A 5 ms timer racing a file read",
|
|
321
|
+
"summary": "A file read on the thread pool races a 5 ms timer. In this recording, made on Windows, the file read won, as it did in 195 of 200 plain runs on this machine. A pause in JavaScript, for example at a breakpoint, can flip the order: the clock and the pool thread keep running while JavaScript waits.",
|
|
322
|
+
"recording": "timer-vs-file-read.nmrec.gz",
|
|
323
|
+
"node": "26.13.1",
|
|
324
|
+
"steps": [
|
|
325
|
+
{
|
|
326
|
+
"index": 25,
|
|
327
|
+
"title": "The read goes to the thread pool",
|
|
328
|
+
"text": "fs.readFile handed one job to the thread pool: the \"fs.readFile\" request. Open the Thread pool tab."
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"index": 33,
|
|
332
|
+
"title": "The 5 ms timer is set",
|
|
333
|
+
"text": "Then setTimeout set a 5 ms timer, the \"setTimeout 5 ms\" chip under Timers. From now on the file read and the clock race each other."
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"index": 35,
|
|
337
|
+
"title": "The read finishes",
|
|
338
|
+
"text": "The pool thread finished the read, and the result waits under \"Finished, waiting for delivery\". Thread times come from trace events that reach nodejs-map late, so their place against main-thread events is approximate."
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"index": 41,
|
|
342
|
+
"title": "The file callback wins",
|
|
343
|
+
"text": "The file callback runs first, in the pending step right after poll (Windows; inferred, rule P1w)."
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"index": 63,
|
|
347
|
+
"title": "Then the timer",
|
|
348
|
+
"text": "The timer runs in the timers phase after it. Timers shows how late it started against its due time; that lateness is nodejs-map's arithmetic from the delay, not a report from Node."
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"id": "fs-sync-vs-async",
|
|
354
|
+
"title": "fs sync vs async",
|
|
355
|
+
"summary": "readFileSync does its work on the main thread and blocks JavaScript until it is done; fs.stat hands its work to the thread pool and returns at once, and its callback runs later from the event loop. Recorded on Windows.",
|
|
356
|
+
"recording": "fs-sync-vs-async.nmrec.gz",
|
|
357
|
+
"node": "26.13.1",
|
|
358
|
+
"steps": [
|
|
359
|
+
{
|
|
360
|
+
"index": 30,
|
|
361
|
+
"title": "Synchronous: on the main thread",
|
|
362
|
+
"text": "readFileSync already returned the text. Node reported its open, read and close as fs.sync events from the main thread (Events tab), and nothing went to the thread pool."
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"index": 37,
|
|
366
|
+
"title": "Asynchronous: a request for the pool",
|
|
367
|
+
"text": "fs.stat created a request, the \"fs.stat\" chip, and handed it to the thread pool, then returned at once."
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"index": 39,
|
|
371
|
+
"title": "The script does not wait",
|
|
372
|
+
"text": "The next line prints before the stat result exists: the request is still listed under \"Requests with the pool\"."
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"index": 49,
|
|
376
|
+
"title": "The callback comes from the loop",
|
|
377
|
+
"text": "The result arrives on a loop turn and the callback runs (pending step after poll on Windows; inferred). For a classic request like stat Node reports no thread events, so the Thread pool tab cannot say which thread ran it (rule W6)."
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"id": "fs-promises-await",
|
|
383
|
+
"title": "fs.promises with await",
|
|
384
|
+
"summary": "An async function makes a temp folder, writes, reads and removes it with fs.promises. Each await gives up the main thread until a file system request comes back; the code after it runs as a microtask. Recorded on Windows; there, fsp.rm with recursive: true took seven separate requests.",
|
|
385
|
+
"recording": "fs-promises-await.nmrec.gz",
|
|
386
|
+
"node": "26.13.1",
|
|
387
|
+
"steps": [
|
|
388
|
+
{
|
|
389
|
+
"index": 17,
|
|
390
|
+
"title": "Synchronous up to the first await",
|
|
391
|
+
"text": "main() runs as part of the main script until its first await, fsp.mkdtemp."
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
"index": 34,
|
|
395
|
+
"title": "main() is suspended",
|
|
396
|
+
"text": "The await on mkdtemp suspended main(), so the main script carries on. The \"fs.mkdtemp\" request (type FSREQPROMISE) is with the thread pool."
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"index": 40,
|
|
400
|
+
"title": "nextTick before any file result",
|
|
401
|
+
"text": "The nextTick runs as soon as the main script is done; no file result has come back yet."
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"index": 102,
|
|
405
|
+
"title": "Resumed after the write",
|
|
406
|
+
"text": "The write finished on the thread pool, and the code after `await fsp.writeFile` runs as a microtask (Stack tab), in the same loop step as the request's callback."
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"index": 144,
|
|
410
|
+
"title": "Read back",
|
|
411
|
+
"text": "The same happens for the read: one trip to the pool, then a microtask continues main()."
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"index": 280,
|
|
415
|
+
"title": "Seven requests to remove a folder",
|
|
416
|
+
"text": "fsp.rm with recursive: true made seven requests one after another (lstat, lstat, rmdir, scandir, lstat, unlink, rmdir), each one a trip to the pool and back. Only then does main() resolve."
|
|
417
|
+
}
|
|
418
|
+
]
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"id": "pbkdf2-six-jobs-four-threads",
|
|
422
|
+
"title": "Six pbkdf2 jobs on four threads",
|
|
423
|
+
"summary": "Six pbkdf2 hashes are handed to the default thread pool of four threads. Four start at once; jobs 5 and 6 wait until a thread is free. In this recording, made on Windows, jobs 1 to 4 finished first, as in 189 of 200 plain runs on this machine; otherwise a thread started a job late.",
|
|
424
|
+
"recording": "pbkdf2-six-jobs-four-threads.nmrec.gz",
|
|
425
|
+
"node": "26.13.1",
|
|
426
|
+
"steps": [
|
|
427
|
+
{
|
|
428
|
+
"index": 42,
|
|
429
|
+
"title": "Four threads, four jobs",
|
|
430
|
+
"text": "Jobs 1 to 4 each got a pool thread right away. The Thread pool tab shows all four threads busy, each with a \"crypto.pbkdf2\" request."
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
"index": 50,
|
|
434
|
+
"title": "Jobs 5 and 6 wait",
|
|
435
|
+
"text": "Jobs 5 and 6 were handed over too, but every thread is busy, so they wait under \"Waiting for a thread\". That a job was handed to the pool is inferred from the request Node created (rule QW)."
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"index": 67,
|
|
439
|
+
"title": "A thread finishes...",
|
|
440
|
+
"text": "Then the first thread finished its job. Each of these hashes keeps a thread busy for a while, and nothing else runs on that thread meanwhile."
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"index": 69,
|
|
444
|
+
"title": "...and takes job 5",
|
|
445
|
+
"text": "The same thread picked up job 5 straight away. The pool has one first-in, first-out queue, so the waiting jobs start in the order they were handed over."
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
"index": 74,
|
|
449
|
+
"title": "The first result comes back",
|
|
450
|
+
"text": "The finished job's callback runs on the main thread, in the pending step after poll (Windows; inferred)."
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"index": 113,
|
|
454
|
+
"title": "Wave 1",
|
|
455
|
+
"text": "Four results are in: jobs 1 to 4, which started first."
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"index": 144,
|
|
459
|
+
"title": "Wave 2, one job-time later",
|
|
460
|
+
"text": "Jobs 5 and 6 finish about one job's duration after the others, because they had to wait for a free thread."
|
|
461
|
+
}
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"id": "pool-with-two-threads",
|
|
466
|
+
"title": "The thread pool with two threads",
|
|
467
|
+
"summary": "Four pbkdf2 jobs on a pool of two threads run in two waves of two. The program sets UV_THREADPOOL_SIZE to 2 itself, before it first uses the pool; nodejs-map learns the size from that variable when the pool starts. Recorded on Windows.",
|
|
468
|
+
"recording": "pool-with-two-threads.nmrec.gz",
|
|
469
|
+
"node": "26.13.1",
|
|
470
|
+
"steps": [
|
|
471
|
+
{
|
|
472
|
+
"index": 18,
|
|
473
|
+
"title": "The program sets the pool size",
|
|
474
|
+
"text": "The program set UV_THREADPOOL_SIZE to 2 itself. Node does not report the pool size: nodejs-map read the variable when the first \"crypto.pbkdf2\" job was handed to the pool, which is when libuv creates its threads, so the size of 2 is marked inferred (rule W7)."
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"index": 29,
|
|
478
|
+
"title": "Two threads, both busy",
|
|
479
|
+
"text": "The Thread pool tab now shows two threads, and jobs 1 and 2 are running on them."
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"index": 37,
|
|
483
|
+
"title": "Jobs 3 and 4 wait",
|
|
484
|
+
"text": "Jobs 3 and 4 are handed over while both threads are busy, so they wait."
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"index": 56,
|
|
488
|
+
"title": "A free thread takes job 3",
|
|
489
|
+
"text": "The first thread to finish its job picked up job 3 straight away."
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
"index": 76,
|
|
493
|
+
"title": "Wave 1",
|
|
494
|
+
"text": "Jobs 1 and 2 are done."
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
"index": 107,
|
|
498
|
+
"title": "Wave 2",
|
|
499
|
+
"text": "Jobs 3 and 4 finish about one job's duration later. With four threads all four jobs would have run at once."
|
|
500
|
+
}
|
|
501
|
+
]
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"id": "dns-lookup-thread-pool",
|
|
505
|
+
"title": "dns.lookup uses the thread pool",
|
|
506
|
+
"summary": "dns.lookup(\"localhost\") asks the operating system's resolver (getaddrinfo) on a pool thread. dns.lookup(\"127.0.0.1\") needs no lookup and calls back through nextTick. Node reports dns.lookup only from the main thread, so the pool thread that ran it is not shown. Recorded on Windows; no network is used.",
|
|
507
|
+
"recording": "dns-lookup-thread-pool.nmrec.gz",
|
|
508
|
+
"node": "26.13.1",
|
|
509
|
+
"steps": [
|
|
510
|
+
{
|
|
511
|
+
"index": 18,
|
|
512
|
+
"title": "localhost goes to the pool",
|
|
513
|
+
"text": "dns.lookup(\"localhost\") handed a getaddrinfo request, the \"dns.lookup\" chip, to the thread pool."
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"index": 21,
|
|
517
|
+
"title": "An IP address skips the pool",
|
|
518
|
+
"text": "dns.lookup(\"127.0.0.1\") made no pool request: an IP address needs no lookup, so Node queued its callback with nextTick: a \"nextTick\" chip."
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
"index": 31,
|
|
522
|
+
"title": "Its callback runs first",
|
|
523
|
+
"text": "So the 127.0.0.1 callback runs in the nextTick round right after the script, even before the program's own nextTick, which was queued after it."
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"index": 47,
|
|
527
|
+
"title": "localhost comes back from the pool",
|
|
528
|
+
"text": "The localhost answer arrives on a loop turn (pending step after poll on Windows; inferred). No thread is shown for this job, because Node does not report pool-thread events for dns.lookup (rule W6)."
|
|
529
|
+
}
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
"id": "tcp-round-trip",
|
|
534
|
+
"title": "A local TCP round trip (pending I/O)",
|
|
535
|
+
"summary": "A TCP server and client on 127.0.0.1 exchange \"ping\" and \"pong\" and close. Socket events come from the operating system, not the thread pool. Recorded on Windows, where socket callbacks run in the pending step right after poll (on Linux and macOS inside poll); close callbacks run in the close phase. Node reports none of these phases; nodejs-map infers them.",
|
|
536
|
+
"recording": "tcp-round-trip.nmrec.gz",
|
|
537
|
+
"node": "26.13.1",
|
|
538
|
+
"steps": [
|
|
539
|
+
{
|
|
540
|
+
"index": 26,
|
|
541
|
+
"title": "The server is listening",
|
|
542
|
+
"text": "The listen callback runs and starts the client."
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
"index": 41,
|
|
546
|
+
"title": "A connect request waits",
|
|
547
|
+
"text": "net.connect created a connect request, the \"TCP connect\" chip under Pending I/O. It waits there until the operating system answers; that it waits there is inferred (rule QR)."
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"index": 49,
|
|
551
|
+
"title": "The server sees the connection",
|
|
552
|
+
"text": "The server's connection callback runs. Node did not report the phase: on Windows the poll step only collects socket events and their callbacks run right after it, so the screen shows \"pending (after poll)\", marked inferred (rule P2)."
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"index": 62,
|
|
556
|
+
"title": "The client is connected",
|
|
557
|
+
"text": "The connect request completes and leaves Pending I/O; its callback writes \"ping\"."
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"index": 71,
|
|
561
|
+
"title": "ping arrives",
|
|
562
|
+
"text": "On a later loop turn the server's socket has data. Its callback prints it and answers \"pong\"."
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"index": 100,
|
|
566
|
+
"title": "pong arrives",
|
|
567
|
+
"text": "The client's socket gets \"pong\" on a later loop turn. The server had already asked to close its side (socket.end): a \"stream shutdown\" chip appeared under Pending I/O."
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
"index": 140,
|
|
571
|
+
"title": "The client's close callback",
|
|
572
|
+
"text": "The client's socket has closed, and its close callback runs in the close phase at the end of the loop turn. Node did not report this phase: nodejs-map knows this is a close callback because close() was called on the handle (inferred, rule CL1)."
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
"index": 166,
|
|
576
|
+
"title": "The server closes",
|
|
577
|
+
"text": "The server's close event comes through a nextTick (Stack tab), queued from the server's own code. Nothing is left waiting, and the process exits."
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"id": "beforeexit-and-exit",
|
|
583
|
+
"title": "beforeExit and exit",
|
|
584
|
+
"summary": "When the loop runs out of work Node emits beforeExit, and a listener can schedule more work, which keeps the process alive. exit comes last and only synchronous code runs after it: a timer set there never fires. Recorded on Windows; the order is the same on every system.",
|
|
585
|
+
"recording": "beforeexit-and-exit.nmrec.gz",
|
|
586
|
+
"node": "26.13.1",
|
|
587
|
+
"steps": [
|
|
588
|
+
{
|
|
589
|
+
"index": 30,
|
|
590
|
+
"title": "The last timer",
|
|
591
|
+
"text": "The main timer runs. It was the program's last waiting work: Timers, Immediates and Pending I/O are empty."
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
"index": 45,
|
|
595
|
+
"title": "beforeExit",
|
|
596
|
+
"text": "With the loop out of work Node emits beforeExit. A beforeExit listener is not an async callback, so the main thread shows nothing running; the Events tab shows the BeforeExit scope Node reported."
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
"index": 52,
|
|
600
|
+
"title": "More work from beforeExit",
|
|
601
|
+
"text": "The listener set a new timer, the \"setTimeout 1 ms\" chip under Timers, so the loop has work again and keeps going."
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"index": 59,
|
|
605
|
+
"title": "The new timer runs",
|
|
606
|
+
"text": "The timer set from beforeExit runs in a timers phase like any other."
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"index": 74,
|
|
610
|
+
"title": "beforeExit again",
|
|
611
|
+
"text": "The loop is empty again, so beforeExit is emitted a second time. This time the listener schedules nothing."
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
"index": 87,
|
|
615
|
+
"title": "exit: too late for timers",
|
|
616
|
+
"text": "Now Node emits exit. The exit listener sets a timer, and Timers shows it waiting (\"setTimeout 1 ms\"), but the process ends without running it."
|
|
617
|
+
}
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
]
|
|
621
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|