node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

The `util._extend` API is deprecated. Please use Object.assign() instead.

Open kayinortin opened this issue 1 year ago • 3 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/http-proxy/lib/http-proxy/index.js b/node_modules/http-proxy/lib/http-proxy/index.js
index 977a4b3..739409c 100644
--- a/node_modules/http-proxy/lib/http-proxy/index.js
+++ b/node_modules/http-proxy/lib/http-proxy/index.js
@@ -1,5 +1,5 @@
 var httpProxy = module.exports,
-    extend    = require('util')._extend,
+    extend    = Object.assign,
     parse_url = require('url').parse,
     EE3       = require('eventemitter3'),
     http      = require('http'),

This issue body was partially generated by patch-package.

kayinortin avatar Dec 08 '24 14:12 kayinortin

If you're using http-proxy on a version of Node that deprecates util._extend(), then you've got a huge memory leak (aborted requests not being cleaned up anymore), you may want to use http-proxy-node16 instead (which, coincidentally, also has a fix for this deprecation).

Jimbly avatar Jan 30 '25 13:01 Jimbly

If you're using http-proxy on a version of Node that deprecates Object.assign(), then you've got a huge memory leak (aborted requests not being cleaned up anymore), you may want to use http-proxy-node16 instead (which, coincidentally, also has a fix for this deprecation).

I had the same issue, its util._extend that is depricated, not Object.assign. I'm not really sure how this works (as in contributing to repositories like this) but I created a pull request for the changes that fixed the issue for me, very similar to what @kayinortin did.

AmbitiousApprentice avatar May 27 '25 15:05 AmbitiousApprentice

Sorry, I had a typo in my message, I meant "deprecates util._extend()" of course, as that's what this issue is about (Object.assign is the solution, not the problem). It is already fixed on the (at least slightly maintained) http-proxy-node16 module (along with much bigger issues you'll run into on Node 16+).

Jimbly avatar May 27 '25 18:05 Jimbly