GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: implement randomuuid by jasnell · Pull Request #36729 · nodejs/node

Conversation

@jasnell

@jasnell jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member

/cc @bcoe

Signed-off-by: James M Snell [email protected]

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR, noseratio, bricss, puzpuzpuz, vdeturckheim, dnalborczyk, danilofuchs, derhuerst, bolmaster2, kaznovac, and 9 more reacted with thumbs up emoji igolskyi and mannyluvstacos reacted with hooray emoji ChALkeR, bricss, ctavan, dnalborczyk, danilofuchs, bolmaster2, kaznovac, NikolasMelui, igolskyi, and mannyluvstacos reacted with rocket emoji
All reactions
  • 👍 19 reactions
  • 🎉 2 reactions
  • 🚀 10 reactions
@nodejs-github-bot nodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label Jan 2, 2021
@targos

targos commented Jan 2, 2021

Copy link
Copy Markdown
Member

Is it being added to the WebCrypto spec? I can't find any reference to this method.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mscdex
mscdex reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

@targos:

Is it being added to the WebCrypto spec?

This is based on a proposal by @bcoe being discussed here: https://discourse.wicg.io/t/proposal-rfc4122-v4-uuids/4986. The actual proposal as it currently stands is introduction of a new global function but there's also discussion about it being exposed via Web Crypto.

targos reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread test/parallel/test-webcrypto-randomuuid.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR previously requested changes Jan 2, 2021
View reviewed changes

@ChALkeR ChALkeR left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data[6]/data[8] is incorrect, otherwise big +1 on this!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread doc/api/webcrypto.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread test/parallel/test-webcrypto-randomuuid.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread test/parallel/test-webcrypto-randomuuid.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

Updated to resolve the comments. Also batched the random data generation to cover generating up to 64 uuid's before having to generate the random data again -- yields a significant performance bump (from ~200k ops/sec up to ~1.8 million / ops/sec) at a minor memory cost.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR
ChALkeR dismissed their stale review January 2, 2021 17:42

Fixed

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/35203/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread lib/internal/crypto/random.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@panva

panva commented Jan 2, 2021

Copy link
Copy Markdown
Member

Adding to the SubtleCrypto interface is imho premature. Otherwise it's a nice addition.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jan 2, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@jasnell how about this:

const hexDigits = [
  48, 49, 50, 51, 52, 53, 54, 55,
  56, 57, 97, 98, 99, 100, 101, 102
];

// Implements an RFC 4122 version 4 random UUID.
// To improve performance, random data is generated in batches
// large enough to cover 64 UUID's at a time.
// The uuidData array and uuid buffer are reused for each.
// Each uuid consumes 16 bytes of random data from the array.
const uuidBatches = 64; // a buffer for this many uuids is prefilled
let uuidBatch = 0;
let uuidData;
let uuid;
function randomUUID() {
  if (uuidData === undefined) {
    uuidData = new Uint8Array(16 * uuidBatches);
    uuid = Buffer.alloc(36, '-');
  }

  if (uuidBatch === 0) getRandomValues(uuidData);
  const base = 16 * uuidBatch;
  uuidBatch = (uuidBatch + 1) % uuidBatches;

  // Version byte: 0100xxxx (version 4)
  uuidData[base + 6] = (uuidData[base + 6] & 0xf) | 0x40;

  // Variant byte: 10xxxxxx (variant 1)
  uuidData[base + 8] = (uuidData[base + 8] & 0x3f) | 0x80;

  let p = 0;
  for (let n = base; n < base + 16; n++) {
    uuid[p++] = hexDigits[(uuidData[n] & 0xf0) >> 4];
    uuid[p++] = hexDigits[(uuidData[n] & 0xf)];
    if (p === 8 || p === 13 || p === 18 || p === 23) p++;
  }

  return uuid.toString();
}

Changes:

  • Split random data buffer from stringification buffer to improve clarity
  • Fixed 63 -> 64 and simplified the logic (starts with 0, use %).
    I doubt there is any effect on performance, but that could be reverted if there is.
  • No need to set '-' each time, can pre-fill those and just skip those bytes.
  • No allocUnsafe()
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell
jasnell force-pushed the randomuuid branch 2 times, most recently from 015a317 to ecfb692 Compare January 2, 2021 18:30
@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

That works @ChALkeR and the performance is looking really good now also...

image

ChALkeR and ballonura reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/35204/

(but it looks like CI is still broken ... @nodejs/build)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

@panva:

Adding to the SubtleCrypto interface is imho premature

Well, it's exposed via require('crypto').webcrypto (at the same level as getRandomBytes() but is not on SubtleCrypto. We can mark it experimental for now giving room for us to move it around as necessary later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ChALkeR
ChALkeR reviewed Jan 2, 2021
View reviewed changes
Comment thread test/parallel/test-webcrypto-randomuuid.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@panva

panva commented Jan 2, 2021

Copy link
Copy Markdown
Member

We can mark it experimental for now giving room for us to move it around as necessary later.

But that benefits noone - if I can have it stable in 'crypto' why would i ever require it from webcrypto, knowing it can get renamed/removed in the future. Just have it stable in crypto and if/when picked up by w3c it can be added to webcrypto.

ChALkeR and ctavan reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jan 2, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

+1 to what @panva said, can we expose that on require('crypto') for now, and not on require('crypto').webcrypto, until it gets into upstream spec?

Implementation LGTM.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 2, 2021

Copy link
Copy Markdown
Member Author

But that benefits noone - if I can have it stable in 'crypto' why would i ever require it from webcrypto, knowing it can get renamed/removed in the future. Just have it stable in crypto and if/when picked up by w3c it can be added to webcrypto.

Partially because the API proposal is still being discussed and could end up being quite a bit different in the end. I'd rather not mark it stable prematurely.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva

panva commented Jan 2, 2021

Copy link
Copy Markdown
Member

@jasnell, fine, but still - we can have that in node's crypto only. Imho it doesn't make sense in webcrypto until it gets picked up by the standards body maintaining that namespace.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell
jasnell force-pushed the randomuuid branch from ecfb692 to 4b5ddbc Compare January 2, 2021 18:53
danielleadams added a commit that referenced this pull request Jan 15, 2021
@danielleadams
2021-01-14, Version 15.6.0 (Current)
0f78948
PR-URL: #36889

Notable changes:

* child_process:
  * add 'overlapped' stdio flag (Thiago Padilha) (#29412)
  * support AbortSignal in fork (Benjamin Gruenbaum) (#36603)
* crypto:
  * implement basic secure heap support (James M Snell) (#36779)
  * fixup bug in keygen error handling (James M Snell) (#36779)
  * introduce X509Certificate API (James M Snell) (#36804)
  * implement randomuuid (James M Snell) (#36729)
* doc:
  * update release key for Danielle Adams (Danielle Adams) (#36793)
  * add dnlup to collaborators (Daniele Belardi) (#36849)
  * add panva to collaborators (Filip Skokan) (#36802)
  * add yashLadha to collaborator (Yash Ladha) (#36666)
* http:
  * set lifo as the default scheduling strategy in Agent (Matteo Collina) (#36685)
* net:
  * support abortSignal in server.listen (Nitzan Uziely) (#36623)
* process:
  * add direct access to rss without iterating pages (Adrien Maret) (#34291)
* v8:
  * fix native  constructors (ExE Boss) (#36549)
jasnell added a commit to jasnell/node that referenced this pull request Jan 15, 2021
@jasnell
crypto: implement randomuuid
1b3860c
Signed-off-by: James M Snell <[email protected]>
Original-PR-URL: nodejs#36729
@jasnell jasnell mentioned this pull request Jan 15, 2021
[v14.x Backport] crypto: implement randomuuid #36945
Closed
@bcoe bcoe mentioned this pull request Jan 18, 2021
refactor: move randomUUID to Crypto WICG/uuid#3
Merged
@puzpuzpuz puzpuzpuz mentioned this pull request Jan 19, 2021
crypto: add buffering to randomInt #35110
Closed
3 tasks done
jasnell added a commit that referenced this pull request Jan 22, 2021
@jasnell
crypto: implement randomuuid
3aeaaea
Signed-off-by: James M Snell <[email protected]>
Original-PR-URL: #36729
PR-URL: #36945
Reviewed-By: Ben Coe <[email protected]>
@aduh95 aduh95 added the backport-open-v14.x label Feb 8, 2021
@srknzl srknzl mentioned this pull request Apr 4, 2021
Add pseudo random number generator info to randomUUID #38074
Merged
Trott pushed a commit to srknzl/node that referenced this pull request Apr 11, 2021
Serkan Özel @Trott
doc: mention cryptographic prng in description of randomUUID
993a1da
PR-URL: nodejs#38074
Refs: nodejs#36729
Reviewed-By: Rich Trott <[email protected]>
targos pushed a commit to jasnell/node that referenced this pull request Apr 24, 2021
@jasnell @targos
crypto: implement randomuuid
ab5e466
Signed-off-by: James M Snell <[email protected]>

PR-URL: nodejs#36729
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Ben Coe <[email protected]>
@targos targos added backported-to-v14.x and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. backport-open-v14.x labels Apr 25, 2021
targos pushed a commit that referenced this pull request Apr 25, 2021
@jasnell @targos
crypto: implement randomuuid
08f9130
Signed-off-by: James M Snell <[email protected]>

PR-URL: #36729
Backport-PR-URL: #36945
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Ben Coe <[email protected]>
targos pushed a commit that referenced this pull request May 1, 2021
Serkan Özel @targos
doc: mention cryptographic prng in description of randomUUID
4350bf5
PR-URL: #38074
Refs: #36729
Reviewed-By: Rich Trott <[email protected]>
@danielleadams danielleadams mentioned this pull request May 3, 2021
v14.17.0 proposal #38507
Merged
danielleadams added a commit that referenced this pull request May 7, 2021
@danielleadams
2021-05-11, Version 14.17.0 Fermium (LTS)
8798145
PR-URL: #38507

Notable changes:

* assert:
  * change status of legacy asserts (James M Snell) (#38113)
* crypto:
  * implement randomuuid (James M Snell) (#36729)
* doc:
  * apply style for legacy status (James M Snell) (#37784)
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* lib:
  * create diagnostics\_channel module (Stephen Belanger) (#34895)
  * implement AbortSignal.abort() (James M Snell) (#37693)
* test:
  * update dom/abort tests (James M Snell) (#37693)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)
danielleadams pushed a commit that referenced this pull request May 8, 2021
Serkan Özel @danielleadams
doc: mention cryptographic prng in description of randomUUID
df8736f
PR-URL: #38074
Refs: #36729
Reviewed-By: Rich Trott <[email protected]>
danielleadams added a commit that referenced this pull request May 8, 2021
@danielleadams
2021-05-11, Version 14.17.0 Fermium (LTS)
523b431
PR-URL: #38507

Notable changes:

* crypto:
  * implement randomuuid (James M Snell) (#36729)
* doc:
  * apply style for legacy status (James M Snell) (#37784)
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* lib:
  * create diagnostics\_channel module (Stephen Belanger) (#34895)
  * implement AbortSignal.abort() (James M Snell) (#37693)
* test:
  * update dom/abort tests (James M Snell) (#37693)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)
danielleadams added a commit that referenced this pull request May 10, 2021
@danielleadams
2021-05-11, Version 14.17.0 Fermium (LTS)
bd2b27f
Notable changes:

Diagnostics channel (experimental module):

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

The module was initially introduced in Node.js v15.1.0 and is backported to v14.17.0
to enable testing it at a larger scale.

With `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 `dc.channel(name)` and call `channel.publish(data)` to send the data to any listeners to that channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

MySQL.prototype.query = function query(queryString, values, callback) {
  // Broadcast query information whenever a query is made
  channel.publish({
    query: queryString,
    host: this.hostname,
  });

  this.doQuery(queryString, values, callback);
};
```

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 `channel.subscribe(listener)` to run a function whenever a message is published to that channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

channel.subscribe(({ query, host }) => {
  console.log(`mysql query to ${host}: ${query}`);
});
```

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).

UUID support in the crypto module:

The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4 UUID strings:

```js
const { randomUUID } = require('crypto');

console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```

Contributed by James M Snell (#36729.

Experimental support for `AbortController` and `AbortSignal`:

Node.js 14.17.0 adds experimental partial support for `AbortController` and `AbortSignal`.

Both constructors can be enabled globally using the `--experimental-abortcontroller` flag.

Additionally, several Node.js APIs have been updated to support `AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any spec-compliant third-party alternatives
should be compatible.

`AbortSignal` support was added to the following methods:

* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`

Other notable changes:

* doc:
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)

PR-URL: #38507
danielleadams added a commit that referenced this pull request May 11, 2021
@danielleadams
2021-05-11, Version 14.17.0 'Fermium' (LTS), @danielleadams
d132e9d
Notable Changes:

Diagnostics channel (experimental module):

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

The module was initially introduced in Node.js v15.1.0 and is
backported to v14.17.0 to enable testing it at a larger scale.

With `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 `dc.channel(name)` and call
`channel.publish(data)` to send the data to any listeners to that
channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

MySQL.prototype.query = function query(queryString, values, callback) {
  // Broadcast query information whenever a query is made
  channel.publish({
    query: queryString,
    host: this.hostname,
  });

  this.doQuery(queryString, values, callback);
};
```

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
`channel.subscribe(listener)` to run a function whenever a message is
published to that channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

channel.subscribe(({ query, host }) => {
  console.log(`mysql query to ${host}: ${query}`);
});
```

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).

UUID support in the crypto module:

The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4
UUID strings:

```js
const { randomUUID } = require('crypto');

console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```

Contributed by James M Snell (#36729).

Experimental support for `AbortController` and `AbortSignal`:

Node.js 14.17.0 adds experimental partial support for `AbortController`
and `AbortSignal`.

Both constructors can be enabled globally using the
`--experimental-abortcontroller` flag.

Additionally, several Node.js APIs have been updated to support
`AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any
spec-compliant third-party alternatives should be compatible.

`AbortSignal` support was added to the following methods:

* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`

Other notable changes:

* doc:
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)

PR-URL: #38507
danielleadams added a commit that referenced this pull request May 11, 2021
@danielleadams
2021-05-11, Version 14.17.0 'Fermium' (LTS)
aa15690
Notable Changes:

Diagnostics channel (experimental module):

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

The module was initially introduced in Node.js v15.1.0 and is
backported to v14.17.0 to enable testing it at a larger scale.

With `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 `dc.channel(name)` and call
`channel.publish(data)` to send the data to any listeners to that
channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

MySQL.prototype.query = function query(queryString, values, callback) {
  // Broadcast query information whenever a query is made
  channel.publish({
    query: queryString,
    host: this.hostname,
  });

  this.doQuery(queryString, values, callback);
};
```

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
`channel.subscribe(listener)` to run a function whenever a message is
published to that channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

channel.subscribe(({ query, host }) => {
  console.log(`mysql query to ${host}: ${query}`);
});
```

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).

UUID support in the crypto module:

The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4
UUID strings:

```js
const { randomUUID } = require('crypto');

console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```

Contributed by James M Snell (#36729).

Experimental support for `AbortController` and `AbortSignal`:

Node.js 14.17.0 adds experimental partial support for `AbortController`
and `AbortSignal`.

Both constructors can be enabled globally using the
`--experimental-abortcontroller` flag.

Additionally, several Node.js APIs have been updated to support
`AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any
spec-compliant third-party alternatives should be compatible.

`AbortSignal` support was added to the following methods:

* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`

Other notable changes:

* doc:
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)

PR-URL: #38507
danielleadams added a commit that referenced this pull request May 11, 2021
@danielleadams
2021-05-11, Version 14.17.0 'Fermium' (LTS)
16e00a1
Notable Changes:

Diagnostics channel (experimental module):

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

The module was initially introduced in Node.js v15.1.0 and is
backported to v14.17.0 to enable testing it at a larger scale.

With `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 `dc.channel(name)` and call
`channel.publish(data)` to send the data to any listeners to that
channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

MySQL.prototype.query = function query(queryString, values, callback) {
  // Broadcast query information whenever a query is made
  channel.publish({
    query: queryString,
    host: this.hostname,
  });

  this.doQuery(queryString, values, callback);
};
```

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
`channel.subscribe(listener)` to run a function whenever a message is
published to that channel.

```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');

channel.subscribe(({ query, host }) => {
  console.log(`mysql query to ${host}: ${query}`);
});
```

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).

UUID support in the crypto module:

The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4
UUID strings:

```js
const { randomUUID } = require('crypto');

console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```

Contributed by James M Snell (#36729).

Experimental support for `AbortController` and `AbortSignal`:

Node.js 14.17.0 adds experimental partial support for `AbortController`
and `AbortSignal`.

Both constructors can be enabled globally using the
`--experimental-abortcontroller` flag.

Additionally, several Node.js APIs have been updated to support
`AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any
spec-compliant third-party alternatives should be compatible.

`AbortSignal` support was added to the following methods:

* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`

Other notable changes:

* doc:
  * revoke deprecation of legacy url, change status to legacy (James M Snell) (#37784)
  * add legacy status to stability index (James M Snell) (#37784)
  * upgrade stability status of report API (Gireesh Punathil) (#35654)
* deps:
  * V8: Backport various patches for Apple Silicon support (BoHong Li) (#38051)
  * update ICU to 68.1 (Michaël Zasso) (#36187)
  * upgrade to libuv 1.41.0 (Colin Ihrig) (#37360)
* http:
  * add http.ClientRequest.getRawHeaderNames() (simov) (#37660)
  * report request start and end with diagnostics\_channel (Stephen Belanger) (#34895)
* util:
  * add getSystemErrorMap() impl (eladkeyshawn) (#38101)

PR-URL: #38507
codebytere added a commit to electron/electron that referenced this pull request May 14, 2021
@codebytere
crypto: implement randomuuid
6fcccf8
nodejs/node#36729
codebytere added a commit to electron/electron that referenced this pull request May 18, 2021
@codebytere
crypto: implement randomuuid
ecc7511
nodejs/node#36729
This was referenced Jun 6, 2022
TypeError: randomUUID is not a function cnpm/cnpm#384
Closed
TypeError: randomUUID is not a function cnpm/npminstall#406
Closed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 24, 2026
Migrate file browser to modular component construction with parent and child API access. vishalpalaniappan/sample-ui-component-library#11
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Apr 14, 2026
Pr request gowthamkishore3799/coderabbit-test#1436
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ChALkeR ChALkeR ChALkeR approved these changes
@tniessen tniessen tniessen left review comments
@mcollina mcollina mcollina approved these changes
@panva panva panva approved these changes
+6 more reviewers
@mscdex mscdex mscdex left review comments
@devsnek devsnek devsnek left review comments
@puzpuzpuz puzpuzpuz puzpuzpuz left review comments
@bcoe bcoe bcoe approved these changes
@ctavan ctavan ctavan approved these changes
@targos targos targos approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

crypto Issues and PRs related to the crypto subsystem. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

16 participants

@jasnell @targos @panva @ChALkeR @mscdex @tniessen @ctavan @broofa @devsnek @nodejs-github-bot @simlu @tlhunter @bcoe @mcollina @puzpuzpuz @aduh95
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.