Notable Changes

Diagnostics channel (experimental module)

1
diagnostics_channel

is a new experimental module that provides an API to create named channels to report arbitrary message data for diagnostics purposes.

With

1
diagnostics_channel

, Node.js core and module authors can publish contextual data about what they are doing at a given time. This could be the hostname and query string of a mysql query, for example. Just create a named channel with

1
dc.channel(name)

and call

1
channel.publish(data)

to send the data to any listeners to that channel.


1
2
3
4
5
6
7
8
9
10
11
12
<span class="token keyword">const</span> dc <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'diagnostics_channel'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> channel <span class="token operator">=</span> dc<span class="token punctuation">.</span><span class="token function">channel</span><span class="token punctuation">(</span><span class="token string">'mysql.query'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token class-name">MySQL</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function-variable function">query</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token function">query</span><span class="token punctuation">(</span><span class="token parameter">queryString<span class="token punctuation">,</span> values<span class="token punctuation">,</span> callback</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// Broadcast query information whenever a query is made</span>
  channel<span class="token punctuation">.</span><span class="token function">publish</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    query<span class="token operator">:</span> queryString<span class="token punctuation">,</span>
    host<span class="token operator">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>hostname<span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">doQuery</span><span class="token punctuation">(</span>queryString<span class="token punctuation">,</span> values<span class="token punctuation">,</span> callback<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

Channels are like one big global event emitter but are split into separate objects to ensure they get the best performance. If nothing is listening to the channel, the publishing overhead should be as close to zero as possible. Consuming channel data is as easy as using

1
channel.subscribe(listener)

to run a function whenever a message is published to that channel.


1
2
3
4
5
6
<span class="token keyword">const</span> dc <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'diagnostics_channel'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> channel <span class="token operator">=</span> dc<span class="token punctuation">.</span><span class="token function">channel</span><span class="token punctuation">(</span><span class="token string">'mysql.query'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

channel<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter"><span class="token punctuation">{</span> query<span class="token punctuation">,</span> host <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">mysql query to </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>host<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>query<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

The data captured can be used to provide context for what an app is doing at a given time. This can be used for things like augmenting tracing data, tracking network and filesystem activity, logging queries, and many other things. It’s also a very useful data source for diagnostics tools to provide a clearer picture of exactly what the application is doing at a given point in the data they are presenting.

Contributed by Stephen Belanger #34895.

New child process

1
'spawn'

event

Instances of

1
ChildProcess

now emit a new

1
'spawn'

event once the child process has spawned successfully.

If emitted, the

1
'spawn'

event comes before all other events and before any data is received via

1
stdout

or

1
stderr

.

The

1
'spawn'

event will fire regardless of whether an error occurs within the spawned process.
For example, if

1
bash some-command

spawns successfully, the

1
'spawn'

event will fire, though

1
bash

may fail to spawn

1
some-command

.
This caveat also applies when using

1
{ shell: true }

.

Contributed by Matthew Francis Brunetti #35369.

Set the local address for DNS resolution

It is now possible to set the local IP address used by a

1
Resolver

instance to send its requests.
This allows programs to specify outbound interfaces when used on multi-homed
systems.

The resolver will use the v4 local address when making requests to IPv4 DNS servers, and the v6 local address when making requests to IPv6 DNS servers.


1
2
3
4
5
6
<span class="token keyword">const</span> <span class="token punctuation">{</span> Resolver <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'dns'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> resolver <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Resolver</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

resolver<span class="token punctuation">.</span><span class="token function">setLocalAddress</span><span class="token punctuation">(</span><span class="token string">'10.1.2.3'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// Equivalent to: resolver.setLocalAddress('10.1.2.3', '::0');</span>

Contributed by Josh Dague #34824.

Control V8 coverage at runtime

The

1
v8

module includes two new methods to control the V8 coverage started by the

1
NODE_V8_COVERAGE

environment variable.

With

1
v8.takeCoverage()

, it is possible to write a coverage report to disk on demand. This can be done multiple times during the lifetime of the process, and the execution counter will be reset on each call.
When the process is about to exit, one last coverage will still be written to disk, unless

1
v8.stopCoverage()

was invoked before.

The

1
v8.stopCoverage()

method allows to stop the coverage collection, so that V8 can release the execution counters and optimize code.

Contributed by Joyee Cheung #33807.

Analyze Worker’s event loop utilization

1
Worker

instances now have a

1
performance

property, with a single

1
eventLoopUtilization

method that can be used to gather information about the worker’s event loop utilization between the

1
'online'

and

1
'exit'

events.

The method works the same way as

1
perf_hooks
1
eventLoopUtilization()

.

Contributed by Trevor Norris #35664.

Take a V8 heap snapshot just before running out of memory (experimental)

With the new

1
--heapsnapshot-near-heap-limit=max_count

experimental command line flag, it is now possible to automatically generate a heap snapshot when the V8 heap usage is approaching the heap limit.

1
count

should be a non-negative integer (in which case Node.js will write no more than

1
max_count

snapshots to disk).

When generating snapshots, garbage collection may be triggered and bring the heap usage down, therefore multiple snapshots may be written to disk before the Node.js instance finally runs out of memory. These heap snapshots can be compared to determine what objects are being allocated during the time consecutive snapshots are taken.

Generating V8 snapshots takes time and memory (both memory managed by the V8 heap and native memory outside the V8 heap). The bigger the heap is, the more resources it needs. Node.js will adjust the V8 heap to accommondate the additional V8 heap memory overhead, and try its best to avoid using up all the memory avialable to the process.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ node --max-old-space-size=100 --heapsnapshot-near-heap-limit=3 index.js
Wrote snapshot to Heap.20200430.100036.49580.0.001.heapsnapshot
Wrote snapshot to Heap.20200430.100037.49580.0.002.heapsnapshot
Wrote snapshot to Heap.20200430.100038.49580.0.003.heapsnapshot

<span class="token entity named-entity" title="&lt;">&amp;lt;</span>--- Last few GCs ---<span class="token entity named-entity" title="&gt;">&amp;gt;</span>

[49580:0x110000000]     4826 ms: Mark-sweep 130.6 (147.8) -<span class="token entity named-entity" title="&gt;">&amp;gt;</span> 130.5 (147.8) MB, 27.4 / 0.0 ms  (average mu = 0.126, current mu = 0.034) allocation failure scavenge might not succeed
[49580:0x110000000]     4845 ms: Mark-sweep 130.6 (147.8) -<span class="token entity named-entity" title="&gt;">&amp;gt;</span> 130.6 (147.8) MB, 18.8 / 0.0 ms  (average mu = 0.088, current mu = 0.031) allocation failure scavenge might not succeed


<span class="token entity named-entity" title="&lt;">&amp;lt;</span>--- JS stacktrace ---<span class="token entity named-entity" title="&gt;">&amp;gt;</span>

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
....

Contributed by Joyee Cheung #33010.

Commits

Semver-minor commits

  • [
    1
    8169902b40

    ] – (SEMVER-MINOR) child_process: add ChildProcess ‘spawn’ event (Matthew Francis Brunetti) #35369

  • [
    1
    548f91af2c

    ] – (SEMVER-MINOR) dns: add setLocalAddress to Resolver (Josh Dague) #34824

  • [
    1
    f861733bac

    ] – (SEMVER-MINOR) http: report request start and end with diagnostics_channel (Stephen Belanger) #34895

  • [
    1
    883ed4b7f1

    ] – (SEMVER-MINOR) http2: add updateSettings to both http2 servers (Vincent Boivin) #35383

  • [
    1
    b38a43d5d9

    ] – (SEMVER-MINOR) lib: create diagnostics_channel module (Stephen Belanger) #34895

  • [
    1
    a7f37bc725

    ] – (SEMVER-MINOR) src: add –heapsnapshot-near-heap-limit option (Joyee Cheung) #33010

  • [
    1
    7bfa872013

    ] – (SEMVER-MINOR) v8: implement v8.stopCoverage() (Joyee Cheung) #33807

  • [
    1
    15ffed5319

    ] – (SEMVER-MINOR) v8: implement v8.takeCoverage() (Joyee Cheung) #33807

  • [
    1
    221e28311f

    ] – (SEMVER-MINOR) worker: add eventLoopUtilization() (Trevor Norris) #35664

Semver-patch commits

Documentation commits

Other commits

Windows 32-bit Installer: https://nodejs.org/dist/v15.1.0/node-v15.1.0-x86.msi
Windows 64-bit Installer: https://nodejs.org/dist/v15.1.0/node-v15.1.0-x64.msi
Windows 32-bit Binary: https://nodejs.org/dist/v15.1.0/win-x86/node.exe
Windows 64-bit Binary: https://nodejs.org/dist/v15.1.0/win-x64/node.exe
macOS 64-bit Installer: https://nodejs.org/dist/v15.1.0/node-v15.1.0.pkg
macOS 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-darwin-x64.tar.gz
Linux 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-x64.tar.xz
Linux PPC LE 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-ppc64le.tar.xz
Linux s390x 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-s390x.tar.xz
AIX 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-aix-ppc64.tar.gz
ARMv7 32-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-armv7l.tar.xz
ARMv8 64-bit Binary: https://nodejs.org/dist/v15.1.0/node-v15.1.0-linux-arm64.tar.xz
Source Code: https://nodejs.org/dist/v15.1.0/node-v15.1.0.tar.gz
Other release files: https://nodejs.org/dist/v15.1.0/
Documentation: https://nodejs.org/docs/v15.1.0/api/

SHASUMS


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

39b7152a34b5d391355c86b4081639b09795853e3fb1b91b3e86ec3eb78a8d07  node-v15.1.0-aix-ppc64.tar.gz
af4d2208a577501464cf39bff4de4d756b2e15b62ba83ab424ac0b5aa3e45c24  node-v15.1.0-darwin-x64.tar.gz
0e4d8469e92d5257c71aa07a5b108c97c7812df8f1afad06e75ac469dc1fc003  node-v15.1.0-darwin-x64.tar.xz
163bc179c76ff60468a137966859446748273db7853c3e11551023c7e425505a  node-v15.1.0-headers.tar.gz
ac86696dd9fe6481f9d9e524bade9055637e684f943402474cbe4db450e4a021  node-v15.1.0-headers.tar.xz
292a5ed3db3ae2acc7cc88bf965c8fca3c39068e867f473f1e2c355549d653b3  node-v15.1.0-linux-arm64.tar.gz
992f640323ba10bfb9c43a464f2be9047568883e127761244a97d0f9a00260dc  node-v15.1.0-linux-arm64.tar.xz
268495b91a6fdc86681f8b890c51c4a6606e5de028c179582c655317707ffbaa  node-v15.1.0-linux-armv7l.tar.gz
6b21bd317158ff790d7a7d035315a48bcffcf7d1ec2cce029ffd3d4ebd58ce1b  node-v15.1.0-linux-armv7l.tar.xz
56a8ccf54cf60208b3b9c082a8589ff5f023c2995243b60b9fb46e6ed87352a0  node-v15.1.0-linux-ppc64le.tar.gz
f0aa31faf68ab3b6dc255aef271e207dcba01b7d35d73ea42897d0c7b223246f  node-v15.1.0-linux-ppc64le.tar.xz
03afd980583cd00b32168585a792bb68b22898f3f1c846dd1eb3899af1727c81  node-v15.1.0-linux-s390x.tar.gz
89f34b9f7a42e6d21919e3a7fe5e6dbe9891a2bc1a86f62b1b967a05bf45b51d  node-v15.1.0-linux-s390x.tar.xz
f7f5d9d313462771095fe121c0dbb95b229a6a8119cb75cace433df748438f20  node-v15.1.0-linux-x64.tar.gz
d049437db2e7b90c3d5afb53fc8dc33dc6069fb43aa05e59c985867fc3813ba6  node-v15.1.0-linux-x64.tar.xz
d3096be91b5268e1ff746e61ea287ec4ee15242a12fae6b73a79948864a26445  node-v15.1.0.pkg
b44e4ac58b0660909e41390c3380a14669480c3f947d078d78d356ce3d1ba4bc  node-v15.1.0.tar.gz
7353d73f06f263b2c90f77a0a189e3ffeb9ea6c0277800e419e9566acd64a0b9  node-v15.1.0.tar.xz
2c179da92d9d03cbe4fac46596abca46d9bd73f66ca577ffaa85794669023142  node-v15.1.0-win-x64.7z
51f172afa35e6bff7096062819e5600672536f26f490f97ee782b30b3cf9c9ba  node-v15.1.0-win-x64.zip
72b4e7be280e92678f8e6d90d7db55d085b5b0e00a8b6e115eb47ddd5c395c82  node-v15.1.0-win-x86.7z
c8dbb260c45b003f43cd838d3a53838f0b7f2e6016ce2aed00e800a58b904200  node-v15.1.0-win-x86.zip
5f98b3247de94a5104da88295152b3a9fe9ea22410d1c2d10ac123fe58bb8050  node-v15.1.0-x64.msi
70302f55f1e9c2ab24e01dd8ef1739f4b760582ad65c2e6f15fc7b14f43c19e2  node-v15.1.0-x86.msi
b3169ae0bf61e3c3276ba4b909b5f8924dec176e86e12c61681638dd17a1015b  win-x64/node.exe
0668ebb22765d3e797c4401f36587f5cc4ada69611e2793cb79209625aca0931  win-x64/node.lib
05275d94016b6dfc12e26ffe94ff05fe3f24fce7d6641842f738a388baa98d12  win-x64/node_pdb.7z
898fd2d6305edb0b45a163bd065ecd92602c2cab1a1afe5128234275b2b446ed  win-x64/node_pdb.zip
09014714b7d1a60a9cd84b782ab41b2f0b3a51a75d8bbe854a7f632fdfcffb85  win-x86/node.exe
3cbb6fca39edc95246ed5169ac8fb1c7e575e45be873dbae255577f66f4d2b2b  win-x86/node.lib
ed3a33829caeb80d9bbd95c6c150f028b292a3c66222db8520ee389033fc9eb2  win-x86/node_pdb.7z
9011efc48fb164347a5514b5c957aa8fdfaeafed38f38f8208f2d30acc2b53ec  win-x86/node_pdb.zip
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEj8yhP+8dDC6RAI4Jdw96mlrhVgAFAl+jFEYACgkQdw96mlrh
VgDTmxAAinKXK6o1QeSIwHB4SRZ6WW3crwcfdVn8BQcGP/X6HdS/wUzAAR/fXTXh
X/eKqMO2tNo54l/s65//NifBLJBWK0C8qZpHl+sFT5TlAk+szVHKFHXP8VFdpspm
2aZC4k3f16tg7RmbvlSXGFvIY/mbHlDTvrYrbqiVYGjlOJVIQL8ciXsRLBwaUtrx
m5fMhMh06jE1zwpuc5NFdsnJd7JoqhTrDq9QFPct9SS9GyEpLRB84QBiXnjoI0ho
s3OBsNZFQ+0KLEWF9yxQgYn8kFOSqhYXLioMMQMADb4aKkUYK0YLtYkmNRYGMv9c
GNM9AStUYFe9qhTZuaH6qbiSKQ6luWgvnH7vX0b/ayl7ej9XOCr/RdhqZ0ijoI0g
0zbC0TRDaWIMDiRMrpu5yHe4aPobS8BZwSf8f3SAlcc+BFsD4qGiKlytdpgXSKao
O7PZvcFHhX5ICRjCZzEKUzr2dDS2VNZv6g4R1yI0vNpXK69voSubnTP/Duh5gYyV
xLdIsWQ8t8VX4Ff14Z0RLq5TXgiuTXvYkYiTTaOIuSxko+ogWtG56UqCaRnKpWkw
32lRLZS4gqlDKbQxljcIsGofcb0nfHF2D9QdT5eXWH8iS+o7lUcsAk9eJZsSDa0W
7h+POihA7uLxnQ7L/Il7BgzY0oyVBXS5YP/65yUXPqo3skyNXps=
=fXhD
-----END PGP SIGNATURE-----
Categories: NewsReleases

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *