From c9aa06a0f156421169f634948f8f035d2537a44b Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Fri, 17 May 2024 09:57:19 +0800 Subject: [PATCH] chore: patch http-proxy compatible with node22 (#16655) --- package.json | 3 ++- patches/http-proxy@1.18.1.patch | 46 +++++++++++++++++++++++++++++++++ pnpm-lock.yaml | 8 ++++-- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 patches/http-proxy@1.18.1.patch diff --git a/package.json b/package.json index 63a09d15a1c6ac..13da5a8356f25f 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,8 @@ }, "patchedDependencies": { "chokidar@3.6.0": "patches/chokidar@3.6.0.patch", - "sirv@2.0.4": "patches/sirv@2.0.4.patch" + "sirv@2.0.4": "patches/sirv@2.0.4.patch", + "http-proxy@1.18.1": "patches/http-proxy@1.18.1.patch" }, "peerDependencyRules": { "allowedVersions": { diff --git a/patches/http-proxy@1.18.1.patch b/patches/http-proxy@1.18.1.patch new file mode 100644 index 00000000000000..04e179137026a3 --- /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 7d5d0fd89ede71..30ebbe595458c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,6 +13,9 @@ patchedDependencies: chokidar@3.6.0: hash: bckcfsslxcffppz65mxcq6naau path: patches/chokidar@3.6.0.patch + http-proxy@1.18.1: + hash: qqiqxx62zlcu62nljjmhlvexni + path: patches/http-proxy@1.18.1.patch sirv@2.0.4: hash: amdes53ifqfntejkflpaq5ifce path: patches/sirv@2.0.4.patch @@ -344,7 +347,7 @@ importers: version: 3.3.2 http-proxy: specifier: ^1.18.1 - version: 1.18.1(debug@4.3.4) + version: 1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni)(debug@4.3.4) launch-editor-middleware: specifier: ^2.6.1 version: 2.6.1 @@ -7224,7 +7227,7 @@ packages: statuses: 2.0.1 toidentifier: 1.0.1 - /http-proxy@1.18.1(debug@4.3.4): + /http-proxy@1.18.1(patch_hash=qqiqxx62zlcu62nljjmhlvexni)(debug@4.3.4): resolution: {integrity: sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==} engines: {node: '>=8.0.0'} dependencies: @@ -7234,6 +7237,7 @@ packages: transitivePeerDependencies: - debug dev: true + patched: true /https-proxy-agent@5.0.1: resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}