nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1Adapted from https://github.com/nodejs/node/pull/58293 for 22.x and 20.x lines.
2
3diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
4index cf7b06d987..369133dafb 100644
5--- a/lib/internal/http2/core.js
6+++ b/lib/internal/http2/core.js
7@@ -30,2 +30,4 @@ const {
8 promisify,
9+ deprecate,
10+ deprecateProperty,
11 SymbolAsyncDispose,
12@@ -713,2 +715,7 @@ function onGoawayData(code, lastStreamID, buf) {
13
14+// TODO(aduh95): remove this in future semver-major
15+const deprecateWeight = deprecateProperty('weight',
16+ 'Priority signaling has been deprecated as of RFC 1993.',
17+ 'DEP0194');
18+
19 // When a ClientHttp2Session is first created, the socket may not yet be
20@@ -741,2 +748,4 @@ function requestOnConnect(headers, options) {
21
22+ deprecateWeight(options);
23+
24 // `ret` will be either the reserved stream ID (if positive)
25@@ -746,3 +755,3 @@ function requestOnConnect(headers, options) {
26 options.parent | 0,
27- options.weight | 0,
28+ NGHTTP2_DEFAULT_WEIGHT,
29 !!options.exclusive);
30@@ -785,7 +794,3 @@ function requestOnConnect(headers, options) {
31 const setAndValidatePriorityOptions = hideStackFrames((options) => {
32- if (options.weight === undefined) {
33- options.weight = NGHTTP2_DEFAULT_WEIGHT;
34- } else {
35- validateNumber.withoutStackTrace(options.weight, 'options.weight');
36- }
37+ deprecateWeight(options);
38
39@@ -845,21 +850,2 @@ function submitSettings(settings, callback) {
40
41-// Submits a PRIORITY frame to be sent to the remote peer
42-// Note: If the silent option is true, the change will be made
43-// locally with no PRIORITY frame sent.
44-function submitPriority(options) {
45- if (this.destroyed)
46- return;
47- this[kUpdateTimer]();
48-
49- // If the parent is the id, do nothing because a
50- // stream cannot be made to depend on itself.
51- if (options.parent === this[kID])
52- return;
53-
54- this[kHandle].priority(options.parent | 0,
55- options.weight | 0,
56- !!options.exclusive,
57- !!options.silent);
58-}
59-
60 // Submit a GOAWAY frame to be sent to the remote peer.
61@@ -2255,21 +2241,2 @@ class Http2Stream extends Duplex {
62
63- priority(options) {
64- if (this.destroyed)
65- throw new ERR_HTTP2_INVALID_STREAM();
66-
67- assertIsObject(options, 'options');
68- options = { ...options };
69- setAndValidatePriorityOptions(options);
70-
71- const priorityFn = submitPriority.bind(this, options);
72-
73- // If the handle has not yet been assigned, queue up the priority
74- // frame to be sent as soon as the ready event is emitted.
75- if (this.pending) {
76- this.once('ready', priorityFn);
77- return;
78- }
79- priorityFn();
80- }
81-
82 sendTrailers(headers) {
83@@ -2431,2 +2398,8 @@ class Http2Stream extends Duplex {
84
85+// TODO(aduh95): remove this in future semver-major
86+Http2Stream.prototype.priority = deprecate(function priority(options) {
87+ if (this.destroyed)
88+ throw new ERR_HTTP2_INVALID_STREAM();
89+}, 'http2Stream.priority is longer supported after priority signalling was deprecated in RFC 1993', 'DEP0194');
90+
91 function callTimeout(self, session) {
92diff --git a/lib/internal/util.js b/lib/internal/util.js
93index 254791eb48..2f12f5a3f1 100644
94--- a/lib/internal/util.js
95+++ b/lib/internal/util.js
96@@ -135,2 +135,13 @@ function isPendingDeprecation() {
97
98+function deprecateProperty(key, msg, code, isPendingDeprecation) {
99+ const emitDeprecationWarning = getDeprecationWarningEmitter(
100+ code, msg, undefined, false, isPendingDeprecation,
101+ );
102+ return (options) => {
103+ if (key in options) {
104+ emitDeprecationWarning();
105+ }
106+ };
107+}
108+
109 // Internal deprecator for pending --pending-deprecation. This can be invoked
110@@ -911,2 +922,3 @@ module.exports = {
111 deprecate,
112+ deprecateProperty,
113 emitExperimentalWarning,