Skip to content

Commit 4e06a64

Browse files
authored
perf_hooks: move deprecated accessors to EOF
Additional accessors on PerformanceEntry objects have been deprecated in favor of the detail property for a number of years now. This removes them. PR-URL: #58531 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent a273674 commit 4e06a64

File tree

4 files changed

+8
-53
lines changed

4 files changed

+8
-53
lines changed

doc/api/deprecations.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,18 +3143,21 @@ an explicit [`"exports"` or `"main"` entry][] with the exact file extension.
31433143

31443144
<!-- YAML
31453145
changes:
3146+
- version: REPLACEME
3147+
pr-url: https://github.com/nodejs/node/pull/58531
3148+
description: End-of-Life.
31463149
- version: v16.0.0
31473150
pr-url: https://github.com/nodejs/node/pull/37136
31483151
description: Runtime deprecation.
31493152
-->
31503153

3151-
Type: Runtime
3154+
Type: End-of-Life
31523155

3153-
The `'gc'`, `'http2'`, and `'http'` {PerformanceEntry} object types have
3156+
The `'gc'`, `'http2'`, and `'http'` {PerformanceEntry} object types used to have
31543157
additional properties assigned to them that provide additional information.
31553158
These properties are now available within the standard `detail` property
3156-
of the `PerformanceEntry` object. The existing accessors have been
3157-
deprecated and should no longer be used.
3159+
of the `PerformanceEntry` object. The deprecated accessors have been
3160+
removed.
31583161

31593162
### DEP0153: `dns.lookup` and `dnsPromises.lookup` options type coercion
31603163

lib/internal/perf/observe.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const {
1414
MathMin,
1515
ObjectDefineProperties,
1616
ObjectFreeze,
17-
ObjectKeys,
1817
SafeMap,
1918
SafeSet,
2019
Symbol,
@@ -57,7 +56,6 @@ const {
5756

5857
const {
5958
customInspectSymbol: kInspect,
60-
deprecate,
6159
lazyDOMException,
6260
kEmptyObject,
6361
kEnumerableProperty,
@@ -74,11 +72,6 @@ const { now } = require('internal/perf/utils');
7472
const kBuffer = Symbol('kBuffer');
7573
const kDispatch = Symbol('kDispatch');
7674
const kMaybeBuffer = Symbol('kMaybeBuffer');
77-
const kDeprecatedFields = Symbol('kDeprecatedFields');
78-
79-
const kDeprecationMessage =
80-
'Custom PerformanceEntry accessors are deprecated. ' +
81-
'Please use the detail property.';
8275

8376
const kTypeSingle = 0;
8477
const kTypeMultiple = 1;
@@ -536,32 +529,6 @@ function observerCallback(name, type, startTime, duration, details) {
536529
duration,
537530
details);
538531

539-
if (details !== undefined) {
540-
// GC, HTTP2, and HTTP PerformanceEntry used additional
541-
// properties directly off the entry. Those have been
542-
// moved into the details property. The existing accessors
543-
// are still included but are deprecated.
544-
entry[kDeprecatedFields] = new SafeMap();
545-
546-
const detailKeys = ObjectKeys(details);
547-
const props = {};
548-
for (let n = 0; n < detailKeys.length; n++) {
549-
const key = detailKeys[n];
550-
entry[kDeprecatedFields].set(key, details[key]);
551-
props[key] = {
552-
configurable: true,
553-
enumerable: true,
554-
get: deprecate(() => {
555-
return entry[kDeprecatedFields].get(key);
556-
}, kDeprecationMessage, 'DEP0152'),
557-
set: deprecate((value) => {
558-
entry[kDeprecatedFields].set(key, value);
559-
}, kDeprecationMessage, 'DEP0152'),
560-
};
561-
}
562-
ObjectDefineProperties(entry, props);
563-
}
564-
565532
enqueue(entry);
566533
}
567534

test/parallel/test-http2-perf_hooks.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ const obs = new PerformanceObserver(common.mustCallAtLeast((items) => {
1616
assert.strictEqual(typeof entry.duration, 'number');
1717
switch (entry.name) {
1818
case 'Http2Session':
19-
assert.strictEqual(typeof entry.pingRTT, 'number');
20-
assert.strictEqual(typeof entry.streamAverageDuration, 'number');
21-
assert.strictEqual(typeof entry.streamCount, 'number');
22-
assert.strictEqual(typeof entry.framesReceived, 'number');
23-
assert.strictEqual(typeof entry.framesSent, 'number');
24-
assert.strictEqual(typeof entry.bytesWritten, 'number');
25-
assert.strictEqual(typeof entry.bytesRead, 'number');
26-
assert.strictEqual(typeof entry.maxConcurrentStreams, 'number');
2719
assert.strictEqual(typeof entry.detail.pingRTT, 'number');
2820
assert.strictEqual(typeof entry.detail.streamAverageDuration, 'number');
2921
assert.strictEqual(typeof entry.detail.streamCount, 'number');
@@ -32,7 +24,7 @@ const obs = new PerformanceObserver(common.mustCallAtLeast((items) => {
3224
assert.strictEqual(typeof entry.detail.bytesWritten, 'number');
3325
assert.strictEqual(typeof entry.detail.bytesRead, 'number');
3426
assert.strictEqual(typeof entry.detail.maxConcurrentStreams, 'number');
35-
switch (entry.type) {
27+
switch (entry.detail.type) {
3628
case 'server':
3729
assert.strictEqual(entry.detail.streamCount, 1);
3830
assert(entry.detail.framesReceived >= 3);
@@ -46,11 +38,6 @@ const obs = new PerformanceObserver(common.mustCallAtLeast((items) => {
4638
}
4739
break;
4840
case 'Http2Stream':
49-
assert.strictEqual(typeof entry.timeToFirstByte, 'number');
50-
assert.strictEqual(typeof entry.timeToFirstByteSent, 'number');
51-
assert.strictEqual(typeof entry.timeToFirstHeader, 'number');
52-
assert.strictEqual(typeof entry.bytesWritten, 'number');
53-
assert.strictEqual(typeof entry.bytesRead, 'number');
5441
assert.strictEqual(typeof entry.detail.timeToFirstByte, 'number');
5542
assert.strictEqual(typeof entry.detail.timeToFirstByteSent, 'number');
5643
assert.strictEqual(typeof entry.detail.timeToFirstHeader, 'number');

test/parallel/test-performance-gc.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ const kinds = [
3030
assert(entry);
3131
assert.strictEqual(entry.name, 'gc');
3232
assert.strictEqual(entry.entryType, 'gc');
33-
assert(kinds.includes(entry.kind));
3433
assert(kinds.includes(entry.detail.kind));
35-
assert.strictEqual(entry.flags, NODE_PERFORMANCE_GC_FLAGS_FORCED);
3634
assert.strictEqual(entry.detail.flags, NODE_PERFORMANCE_GC_FLAGS_FORCED);
3735
assert.strictEqual(typeof entry.startTime, 'number');
3836
assert(entry.startTime < 1e4, 'startTime should be relative to performance.timeOrigin.');

0 commit comments

Comments
 (0)