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

4 files changed

Lines changed: 8 additions & 53 deletions

File tree

‎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
constkBuffer=Symbol('kBuffer');
7573
constkDispatch=Symbol('kDispatch');
7674
constkMaybeBuffer=Symbol('kMaybeBuffer');
77-
constkDeprecatedFields=Symbol('kDeprecatedFields');
78-
79-
constkDeprecationMessage=
80-
'Custom PerformanceEntry accessors are deprecated. '+
81-
'Please use the detail property.';
8275

8376
constkTypeSingle=0;
8477
constkTypeMultiple=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]=newSafeMap();
545-
546-
constdetailKeys=ObjectKeys(details);
547-
constprops={};
548-
for(letn=0;n<detailKeys.length;n++){
549-
constkey=detailKeys[n];
550-
entry[kDeprecatedFields].set(key,details[key]);
551-
props[key]={
552-
configurable: true,
553-
enumerable: true,
554-
get: deprecate(()=>{
555-
returnentry[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(typeofentry.duration,'number');
1717
switch(entry.name){
1818
case'Http2Session':
19-
assert.strictEqual(typeofentry.pingRTT,'number');
20-
assert.strictEqual(typeofentry.streamAverageDuration,'number');
21-
assert.strictEqual(typeofentry.streamCount,'number');
22-
assert.strictEqual(typeofentry.framesReceived,'number');
23-
assert.strictEqual(typeofentry.framesSent,'number');
24-
assert.strictEqual(typeofentry.bytesWritten,'number');
25-
assert.strictEqual(typeofentry.bytesRead,'number');
26-
assert.strictEqual(typeofentry.maxConcurrentStreams,'number');
2719
assert.strictEqual(typeofentry.detail.pingRTT,'number');
2820
assert.strictEqual(typeofentry.detail.streamAverageDuration,'number');
2921
assert.strictEqual(typeofentry.detail.streamCount,'number');
@@ -32,7 +24,7 @@ const obs = new PerformanceObserver(common.mustCallAtLeast((items) => {
3224
assert.strictEqual(typeofentry.detail.bytesWritten,'number');
3325
assert.strictEqual(typeofentry.detail.bytesRead,'number');
3426
assert.strictEqual(typeofentry.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(typeofentry.timeToFirstByte,'number');
50-
assert.strictEqual(typeofentry.timeToFirstByteSent,'number');
51-
assert.strictEqual(typeofentry.timeToFirstHeader,'number');
52-
assert.strictEqual(typeofentry.bytesWritten,'number');
53-
assert.strictEqual(typeofentry.bytesRead,'number');
5441
assert.strictEqual(typeofentry.detail.timeToFirstByte,'number');
5542
assert.strictEqual(typeofentry.detail.timeToFirstByteSent,'number');
5643
assert.strictEqual(typeofentry.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(typeofentry.startTime,'number');
3836
assert(entry.startTime<1e4,'startTime should be relative to performance.timeOrigin.');

0 commit comments

Comments
 (0)