From 8c235df5aa2b0bf0d05b082ee6e6f81571a5a774 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 8 Jan 2025 20:10:04 +0800 Subject: [PATCH 1/2] fix: deprecation warning when using proxy with Node 22 --- package.json | 5 ++++ patches/http-proxy@1.18.1.patch | 46 +++++++++++++++++++++++++++++++++ pnpm-lock.yaml | 9 +++++-- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 patches/http-proxy@1.18.1.patch diff --git a/package.json b/package.json index 174066a52d..29fd75a263 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,11 @@ "typescript": "^5.7.2", "vitest": "^2.1.8" }, + "pnpm": { + "patchedDependencies": { + "http-proxy@1.18.1": "patches/http-proxy@1.18.1.patch" + } + }, "packageManager": "pnpm@9.11.0", "engines": { "node": ">=18.0.0", diff --git a/patches/http-proxy@1.18.1.patch b/patches/http-proxy@1.18.1.patch new file mode 100644 index 0000000000..04e1791370 --- /dev/null +++ b/patches/http-proxy@1.18.1.patch @@ -0,0 +1,46 @@ +diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js +index 6513e81d80d5250ea249ea833f819ece67897c7e..486d4c896d65a3bb7cf63307af68facb3ddb886b 100644 +--- a/lib/http-proxy/common.js ++++ b/lib/http-proxy/common.js +@@ -1,6 +1,5 @@ + var common = exports, + url = require('url'), +- extend = require('util')._extend, + required = require('requires-port'); + + var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i, +@@ -40,10 +39,10 @@ common.setupOutgoing = function(outgoing, options, req, forward) { + ); + + outgoing.method = options.method || req.method; +- outgoing.headers = extend({}, req.headers); ++ outgoing.headers = Object.assign({}, req.headers); + + if (options.headers){ +- extend(outgoing.headers, options.headers); ++ Object.assign(outgoing.headers, options.headers); + } + + if (options.auth) { +diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js +index 977a4b3622b9eaac27689f06347ea4c5173a96cd..88b2d0fcfa03c3aafa47c7e6d38e64412c45a7cc 100644 +--- a/lib/http-proxy/index.js ++++ b/lib/http-proxy/index.js +@@ -1,5 +1,4 @@ + var httpProxy = module.exports, +- extend = require('util')._extend, + parse_url = require('url').parse, + EE3 = require('eventemitter3'), + http = require('http'), +@@ -47,9 +46,9 @@ function createRightProxy(type) { + args[cntr] !== res + ) { + //Copy global options +- requestOptions = extend({}, options); ++ requestOptions = Object.assign({}, options); + //Overwrite with request options +- extend(requestOptions, args[cntr]); ++ Object.assign(requestOptions, args[cntr]); + + cntr--; + } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 885d790d5c..992a4612fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + http-proxy@1.18.1: + hash: qqiqxx62zlcu62nljjmhlvexni + path: patches/http-proxy@1.18.1.patch + importers: .: @@ -10564,14 +10569,14 @@ snapshots: http-proxy-middleware@2.0.7: dependencies: '@types/http-proxy': 1.17.15 - http-proxy: 1.18.1 + http-proxy: 1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni) is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.8 transitivePeerDependencies: - debug - http-proxy@1.18.1: + http-proxy@1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni): dependencies: eventemitter3: 4.0.7 follow-redirects: 1.15.9 From 755cb2c8a2e451ad4a77cdae8a7cb6f400d1b1d6 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 8 Jan 2025 20:21:54 +0800 Subject: [PATCH 2/2] fix: ref --- patches/http-proxy@1.18.1.patch | 1 + pnpm-lock.yaml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/patches/http-proxy@1.18.1.patch b/patches/http-proxy@1.18.1.patch index 04e1791370..0c0c1a060e 100644 --- a/patches/http-proxy@1.18.1.patch +++ b/patches/http-proxy@1.18.1.patch @@ -1,3 +1,4 @@ +# ref: https://github.com/web-infra-dev/rsbuild/issues/4344 diff --git a/lib/http-proxy/common.js b/lib/http-proxy/common.js index 6513e81d80d5250ea249ea833f819ece67897c7e..486d4c896d65a3bb7cf63307af68facb3ddb886b 100644 --- a/lib/http-proxy/common.js diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 992a4612fc..8e636b5ed8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: http-proxy@1.18.1: - hash: qqiqxx62zlcu62nljjmhlvexni + hash: rg7rdv5wkqlu467sapxhhl2w2i path: patches/http-proxy@1.18.1.patch importers: @@ -10569,14 +10569,14 @@ snapshots: http-proxy-middleware@2.0.7: dependencies: '@types/http-proxy': 1.17.15 - http-proxy: 1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni) + http-proxy: 1.18.1(patch_hash=rg7rdv5wkqlu467sapxhhl2w2i) is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.8 transitivePeerDependencies: - debug - http-proxy@1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni): + http-proxy@1.18.1(patch_hash=rg7rdv5wkqlu467sapxhhl2w2i): dependencies: eventemitter3: 4.0.7 follow-redirects: 1.15.9