chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.68k stars 826 forks source link

Deprecation warning for `util._extend` #1017

Closed TheJaredWilcurt closed 1 month ago

TheJaredWilcurt commented 1 month ago

Checks

Describe the bug (be clear and concise)

In Node v22 they started showing a deprecation warning for usage of util._extend, which is used in a dependency of this library.

(node:27864) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
    at ProxyServer.<anonymous> (\node_modules\http-proxy\lib\http-proxy\index.js:50:26)
    at HttpProxyMiddleware.middleware (\node_modules\http-proxy-middleware\dist\http-proxy-middleware.js:22:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

There is a PR for that dependency:

Once that is merged and a new version is released, http-proxy-middleware will need to update the dependency to stop receiving the deprecation warning in Node v22+.

I'm mainly making this issue to encourage prioritization of the linked PR.

Step-by-step reproduction instructions

1. Use library with Node 22+

Expected behavior (be clear and concise)

No deprecation warnings

How is http-proxy-middleware used in your project?

internal-app@1.0.0 C:\internal-app
`-- @internal-library/utils-ui-dev@3.1.1
  `-- http-proxy-middleware@3.0.0.2 deduped
| +-- istanbul-reports@3.1.7

What http-proxy-middleware configuration are you using?

N/A

What OS/version and node/version are you seeing the problem?

Node v22.3.0 - All OS

Additional context (optional)

No response

chimurai commented 1 month ago

Thanks for the report.

With semver, when http-proxy releases a new minor of patch version, there is no need to update this project.

You can just update your package lock file to retrieve updated http-proxy dependency.

https://github.com/chimurai/http-proxy-middleware/blob/82aaf0aefaeb341b87fcd5b0e27a15deb030e57e/package.json#L90

Closing this issue (since no update to http-proxy-middleware is needed when http-proxy releases a minor/patch update)

You can read more about semver: https://semver.org

habahabahaba commented 1 month ago

Hello. I am getting "Deprecation warning for util._extend", when using http-proxy-middleware with Express. My code:

// 3rd party:
import { createProxyMiddleware } from 'http-proxy-middleware';
// Express:
import express from 'express';

export function serve(
  port: number,
  filename: string,
  dir: string
): Promise<void> {
  const app = express();

  app.use(
    createProxyMiddleware({
      target: `http://localhost:5173`,
      ws: true,
    })
  );

  return new Promise<void>((resolve, reject) => {
    app.listen(port, resolve).on('error', reject);
  });
}

My package.json:

{
  "version": "1.0.0",
  "description": "",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "tsc --watch --preserveWatchOutput"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "cors": "^2.8.5",
    "express": "^4.19.2",
    "http-proxy-middleware": "^3.0.0"
  }
}

My error:

(node:26057) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
    at ProxyServer.<anonymous> (.../node_modules/.pnpm/http-proxy@1.18.1_debug@4.3.5/node_modules/http-proxy/lib/http-proxy/index.js:50:26)
    at HttpProxyMiddleware.middleware (.../node_modules/.pnpm/http-proxy-middleware@3.0.0/node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:22:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
btkfrank commented 4 weeks ago

Thanks for the report.

With semver, when http-proxy releases a new minor of patch version, there is no need to update this project.

You can just update your package lock file to retrieve updated http-proxy dependency.

https://github.com/chimurai/http-proxy-middleware/blob/82aaf0aefaeb341b87fcd5b0e27a15deb030e57e/package.json#L90

Closing this issue (since no update to http-proxy-middleware is needed when http-proxy releases a minor/patch update)

You can read more about semver: https://semver.org

http-proxy@1.18.1 is already the latest version, and hasn't been updated for 4 years. And is still using util._extend

Netail commented 1 week ago

@chimurai please reopen this issue again. Facing the same deprecation warning with the lastest version :/

chabb commented 1 week ago

@chimurai You can take a look at the vitejs repo. They patched the http-proxy package to solve this issue : https://github.com/vitejs/vite/pull/16655