Skip to content

Commit b3e21c0

Browse files
mcollinaaduh95
andcommitted
http2: remove support for priority signaling
Signed-off-by: Matteo Collina <[email protected]> Co-authored-by: Antoine du Hamel <[email protected]> Refs: https://datatracker.ietf.org/doc/html/rfc9113#section-5.3.1
1 parent b981253 commit b3e21c0

10 files changed

+81
-84
lines changed

doc/api/deprecations.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3945,15 +3945,17 @@ an internal nodejs implementation rather than a public facing API, use `node:str
39453945

39463946
<!-- YAML
39473947
changes:
3948+
- version: REPLACEME
3949+
pr-url: https://github.com/nodejs/node/pull/58293
3950+
description: End-of-Life.
39483951
- version: REPLACEME
39493952
pr-url: https://github.com/nodejs/node/pull/58313
39503953
description: Documentation-only deprecation.
39513954
-->
39523955

3953-
Type: Documentation-only
3956+
Type: End-of-Life
39543957

3955-
The support for priority signaling has been deprecated in the [RFC 9113][], and
3956-
will be removed in future versions of Node.js.
3958+
The support for priority signaling has been removed following its deprecation in the [RFC 9113][].
39573959

39583960
[DEP0142]: #dep0142-repl_builtinlibs
39593961
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf

doc/api/http2.md

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,10 @@ The `'origin'` event is only emitted when using a secure TLS connection.
10721072
<!-- YAML
10731073
added: v8.4.0
10741074
changes:
1075+
- version: REPLACEME
1076+
pr-url: https://github.com/nodejs/node/pull/58293
1077+
description: The `weight` option is now ignored, setting it will trigger a
1078+
runtime warning.
10751079
- version: REPLACEME
10761080
pr-url: https://github.com/nodejs/node/pull/58313
10771081
description: Following the deprecation of priority signaling as of RFC 1993,
@@ -1090,10 +1094,6 @@ changes:
10901094
**Default:** `false`.
10911095
* `parent` {number} Specifies the numeric identifier of a stream the newly
10921096
created stream is dependent on.
1093-
* `weight` {number} Specifies the relative dependency of a stream in relation
1094-
to other streams with the same `parent`. The value is a number between `1`
1095-
and `256` (inclusive). This has been **deprecated** in [RFC 9113][], and
1096-
support for it will be removed in future versions of Node.js.
10971097
* `waitForTrailers` {boolean} When `true`, the `Http2Stream` will emit the
10981098
`'wantTrailers'` event after the final `DATA` frame has been sent.
10991099
* `signal` {AbortSignal} An AbortSignal that may be used to abort an ongoing
@@ -1464,25 +1464,17 @@ numeric stream identifier.
14641464
<!-- YAML
14651465
added: v8.4.0
14661466
deprecated: REPLACEME
1467+
changes:
1468+
- version: REPLACEME
1469+
pr-url: https://github.com/nodejs/node/pull/58293
1470+
description: This method no longer sets the priority of the stream. Using it
1471+
now triggers a runtime warning.
14671472
-->
14681473

14691474
> Stability: 0 - Deprecated: support for priority signaling has been deprecated
14701475
> in the [RFC 9113][] and is no longer supported in Node.js.
14711476
1472-
* `options` {Object}
1473-
* `exclusive` {boolean} When `true` and `parent` identifies a parent Stream,
1474-
this stream is made the sole direct dependency of the parent, with
1475-
all other existing dependents made a dependent of this stream. **Default:**
1476-
`false`.
1477-
* `parent` {number} Specifies the numeric identifier of a stream this stream
1478-
is dependent on.
1479-
* `weight` {number} Specifies the relative dependency of a stream in relation
1480-
to other streams with the same `parent`. The value is a number between `1`
1481-
and `256` (inclusive).
1482-
* `silent` {boolean} When `true`, changes the priority locally without
1483-
sending a `PRIORITY` frame to the connected peer.
1484-
1485-
Updates the priority for this `Http2Stream` instance.
1477+
Empty method, only there to maintain some backward compatibility.
14861478

14871479
#### `http2stream.rstCode`
14881480

@@ -1579,6 +1571,10 @@ req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));
15791571
<!-- YAML
15801572
added: v8.4.0
15811573
changes:
1574+
- version: REPLACEME
1575+
pr-url: https://github.com/nodejs/node/pull/58293
1576+
description: The `state.weight` property is now always set to 16 and
1577+
`sumDependencyWeight` is always set to 0.
15821578
- version: REPLACEME
15831579
pr-url: https://github.com/nodejs/node/pull/58313
15841580
description: Following the deprecation of priority signaling as of RFC 1993,
@@ -1596,13 +1592,8 @@ Provides miscellaneous information about the current state of the
15961592
* `localClose` {number} `1` if this `Http2Stream` has been closed locally.
15971593
* `remoteClose` {number} `1` if this `Http2Stream` has been closed
15981594
remotely.
1599-
* `sumDependencyWeight` {number} The sum weight of all `Http2Stream`
1600-
instances that depend on this `Http2Stream` as specified using
1601-
`PRIORITY` frames. This has been **deprecated** in [RFC 9113][], and
1602-
support for it will be removed in future versions of Node.js.
1603-
* `weight` {number} The priority weight of this `Http2Stream`. This has been
1604-
**deprecated** in [RFC 9113][], and support for it will be removed in future
1605-
versions of Node.js.
1595+
* `sumDependencyWeight` {number} Legacy property, always set to `0`.
1596+
* `weight` {number} Legacy property, always set to `16`.
16061597

16071598
A current state of this `Http2Stream`.
16081599

lib/internal/http2/core.js

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const {
3030
customInspectSymbol: kInspect,
3131
kEmptyObject,
3232
promisify,
33+
deprecate,
34+
deprecateProperty,
3335
} = require('internal/util');
3436

3537
assertCrypto();
@@ -746,6 +748,11 @@ function onGoawayData(code, lastStreamID, buf) {
746748
}
747749
}
748750

751+
// TODO(aduh95): remove this in future semver-major
752+
const deprecateWeight = deprecateProperty('weight',
753+
'Priority signaling has been deprecated as of RFC 1993.',
754+
'DEP0194');
755+
749756
// When a ClientHttp2Session is first created, the socket may not yet be
750757
// connected. If request() is called during this time, the actual request
751758
// will be deferred until the socket is ready to go.
@@ -774,12 +781,14 @@ function requestOnConnect(headersList, headersParam, options) {
774781
if (options.waitForTrailers)
775782
streamOptions |= STREAM_OPTION_GET_TRAILERS;
776783

784+
deprecateWeight(options);
785+
777786
// `ret` will be either the reserved stream ID (if positive)
778787
// or an error code (if negative)
779788
const ret = session[kHandle].request(headersList,
780789
streamOptions,
781790
options.parent | 0,
782-
options.weight | 0,
791+
NGHTTP2_DEFAULT_WEIGHT,
783792
!!options.exclusive);
784793

785794
// In an error condition, one of three possible response codes will be
@@ -824,11 +833,7 @@ function requestOnConnect(headersList, headersParam, options) {
824833
//
825834
// Also sets the default priority options if they are not set.
826835
const setAndValidatePriorityOptions = hideStackFrames((options) => {
827-
if (options.weight === undefined) {
828-
options.weight = NGHTTP2_DEFAULT_WEIGHT;
829-
} else {
830-
validateNumber.withoutStackTrace(options.weight, 'options.weight');
831-
}
836+
deprecateWeight(options);
832837

833838
if (options.parent === undefined) {
834839
options.parent = 0;
@@ -884,25 +889,6 @@ function submitSettings(settings, callback) {
884889
}
885890
}
886891

887-
// Submits a PRIORITY frame to be sent to the remote peer
888-
// Note: If the silent option is true, the change will be made
889-
// locally with no PRIORITY frame sent.
890-
function submitPriority(options) {
891-
if (this.destroyed)
892-
return;
893-
this[kUpdateTimer]();
894-
895-
// If the parent is the id, do nothing because a
896-
// stream cannot be made to depend on itself.
897-
if (options.parent === this[kID])
898-
return;
899-
900-
this[kHandle].priority(options.parent | 0,
901-
options.weight | 0,
902-
!!options.exclusive,
903-
!!options.silent);
904-
}
905-
906892
// Submit a GOAWAY frame to be sent to the remote peer.
907893
// If the lastStreamID is set to <= 0, then the lastProcStreamID will
908894
// be used. The opaqueData must either be a typed array or undefined
@@ -2312,25 +2298,6 @@ class Http2Stream extends Duplex {
23122298
}
23132299
}
23142300

2315-
priority(options) {
2316-
if (this.destroyed)
2317-
throw new ERR_HTTP2_INVALID_STREAM();
2318-
2319-
assertIsObject(options, 'options');
2320-
options = { ...options };
2321-
setAndValidatePriorityOptions(options);
2322-
2323-
const priorityFn = submitPriority.bind(this, options);
2324-
2325-
// If the handle has not yet been assigned, queue up the priority
2326-
// frame to be sent as soon as the ready event is emitted.
2327-
if (this.pending) {
2328-
this.once('ready', priorityFn);
2329-
return;
2330-
}
2331-
priorityFn();
2332-
}
2333-
23342301
sendTrailers(headers) {
23352302
if (this.destroyed || this.closed)
23362303
throw new ERR_HTTP2_INVALID_STREAM();
@@ -2496,6 +2463,12 @@ class Http2Stream extends Duplex {
24962463
}
24972464
}
24982465

2466+
// TODO(aduh95): remove this in future semver-major
2467+
Http2Stream.prototype.priority = deprecate(function priority(options) {
2468+
if (this.destroyed)
2469+
throw new ERR_HTTP2_INVALID_STREAM();
2470+
}, 'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993', 'DEP0194');
2471+
24992472
function callTimeout(self, session) {
25002473
// If the session is destroyed, this should never actually be invoked,
25012474
// but just in case...

lib/internal/util.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ function isPendingDeprecation() {
135135
!getOptionValue('--no-deprecation');
136136
}
137137

138+
function deprecateProperty(key, msg, code, isPendingDeprecation) {
139+
const emitDeprecationWarning = getDeprecationWarningEmitter(
140+
code, msg, undefined, false, isPendingDeprecation,
141+
);
142+
return (options) => {
143+
if (key in options) {
144+
emitDeprecationWarning();
145+
}
146+
};
147+
}
148+
138149
// Internal deprecator for pending --pending-deprecation. This can be invoked
139150
// at snapshot building time as the warning permission is only queried at
140151
// run time.
@@ -947,6 +958,7 @@ module.exports = {
947958
defineReplaceableLazyAttribute,
948959
deprecate,
949960
deprecateInstantiation,
961+
deprecateProperty,
950962
emitExperimentalWarning,
951963
encodingsMap,
952964
exposeInterface,

test/parallel/test-http2-client-priority-before-connect.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ if (!common.hasCrypto)
55
common.skip('missing crypto');
66
const h2 = require('http2');
77

8+
common.expectWarning(
9+
'DeprecationWarning',
10+
'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993',
11+
'DEP0194');
12+
813
const server = h2.createServer();
914

1015
// We use the lower-level API here

test/parallel/test-http2-client-request-options-errors.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const http2 = require('http2');
1111

1212
const optionsToTest = {
1313
endStream: 'boolean',
14-
weight: 'number',
1514
parent: 'number',
1615
exclusive: 'boolean',
1716
silent: 'boolean'

test/parallel/test-http2-client-set-priority.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ if (!common.hasCrypto)
66
const assert = require('assert');
77
const http2 = require('http2');
88

9+
common.expectWarning(
10+
'DeprecationWarning',
11+
'Priority signaling has been deprecated as of RFC 1993.',
12+
'DEP0194');
13+
914
const checkWeight = (actual, expect) => {
1015
const server = http2.createServer();
1116
server.on('stream', common.mustCall((stream, headers, flags) => {
12-
assert.strictEqual(stream.state.weight, expect);
17+
assert.strictEqual(stream.state.sumDependencyWeight, 0);
18+
assert.strictEqual(stream.state.weight, 16);
1319
stream.respond();
1420
stream.end('test');
1521
}));

test/parallel/test-http2-priority-cycle-.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ const assert = require('assert');
77
const http2 = require('http2');
88
const Countdown = require('../common/countdown');
99

10+
common.expectWarning(
11+
'DeprecationWarning',
12+
'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993',
13+
'DEP0194');
14+
1015
const server = http2.createServer();
1116
const largeBuffer = Buffer.alloc(1e4);
1217

test/parallel/test-http2-priority-event.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
const common = require('../common');
44
if (!common.hasCrypto)
55
common.skip('missing crypto');
6-
const assert = require('assert');
76
const h2 = require('http2');
87

8+
common.expectWarning(
9+
'DeprecationWarning',
10+
'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993',
11+
'DEP0194');
12+
913
const server = h2.createServer();
1014

1115
// We use the lower-level API here
1216
server.on('stream', common.mustCall(onStream));
1317

14-
function onPriority(stream, parent, weight, exclusive) {
15-
assert.strictEqual(stream, 1);
16-
assert.strictEqual(parent, 0);
17-
assert.strictEqual(weight, 1);
18-
assert.strictEqual(exclusive, false);
19-
}
20-
2118
function onStream(stream, headers, flags) {
2219
stream.priority({
2320
parent: 0,
@@ -33,7 +30,7 @@ function onStream(stream, headers, flags) {
3330

3431
server.listen(0);
3532

36-
server.on('priority', common.mustCall(onPriority));
33+
server.on('priority', common.mustNotCall());
3734

3835
server.on('listening', common.mustCall(() => {
3936

@@ -48,7 +45,9 @@ server.on('listening', common.mustCall(() => {
4845
});
4946
});
5047

51-
req.on('priority', common.mustCall(onPriority));
48+
// The priority event is not supported anymore by nghttp2
49+
// since 1.65.0.
50+
req.on('priority', common.mustNotCall());
5251

5352
req.on('response', common.mustCall());
5453
req.resume();

test/parallel/test-http2-server-stream-session-destroy.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ if (!common.hasCrypto)
66
const assert = require('assert');
77
const h2 = require('http2');
88

9+
common.expectWarning(
10+
'DeprecationWarning',
11+
'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993',
12+
'DEP0194');
13+
914
const server = h2.createServer();
1015

1116
server.on('stream', common.mustCall((stream) => {

0 commit comments

Comments
 (0)