• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chimurai / http-proxy-middleware / 25288652707

03 May 2026 07:32PM UTC coverage: 94.07%. Remained the same
25288652707

push

github

web-flow
docs: update http-proxy references to httpxy (#1222)

179 of 198 branches covered (90.4%)

1 of 2 new or added lines in 1 file covered. (50.0%)

349 of 371 relevant lines covered (94.07%)

38.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.57
/src/plugins/default/debug-proxy-errors-plugin.ts
1
import { Debug } from '../../debug.js';
2
import type { Plugin } from '../../types.js';
3

4
const debug = Debug.extend('debug-proxy-errors-plugin');
17✔
5

6
/**
7
 * Subscribe to {@link https://github.com/unjs/httpxy#events `httpxy` error events} to prevent server from crashing.
8
 * Errors are logged with {@link https://www.npmjs.com/package/debug debug} library.
9
 */
10
export const debugProxyErrorsPlugin: Plugin = (proxyServer): void => {
17✔
11
  /**
12
   * http-proxy doesn't handle any errors by default (https://github.com/http-party/node-http-proxy#listening-for-proxy-events)
13
   * Prevent server from crashing when http-proxy errors (uncaught errors)
14
   */
15
  proxyServer.on('error', (error, req, res, target) => {
108✔
16
    debug(`httpxy error event: \n%O`, error);
7✔
17
  });
18

19
  proxyServer.on('proxyReq', (proxyReq, req, socket) => {
108✔
20
    socket.on('error', (error) => {
71✔
21
      debug('Socket error in proxyReq event: \n%O', error);
×
22
    });
23
  });
24

25
  /**
26
   * Fix SSE close events
27
   * @link https://github.com/chimurai/http-proxy-middleware/issues/678
28
   * @link https://github.com/http-party/node-http-proxy/issues/1520#issue-877626125
29
   */
30
  proxyServer.on('proxyRes', (proxyRes, req, res) => {
108✔
31
    res.on('close', () => {
65✔
32
      if (!res.writableEnded) {
65!
33
        debug('Destroying proxyRes in proxyRes close event');
×
34
        proxyRes.destroy();
×
35
      }
36
    });
37
  });
38

39
  /**
40
   * Fix crash when target server restarts
41
   * https://github.com/chimurai/http-proxy-middleware/issues/476#issuecomment-746329030
42
   * https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-790602225
43
   */
44
  proxyServer.on('proxyReqWs', (proxyReq, req, socket) => {
108✔
45
    socket.on('error', (error) => {
4✔
46
      debug('Socket error in proxyReqWs event: \n%O', error);
×
47
    });
48
  });
49

50
  proxyServer.on('open', (proxySocket) => {
108✔
51
    proxySocket.on('error', (error) => {
4✔
52
      debug('Socket error in open event: \n%O', error);
×
53
    });
54
  });
55

56
  proxyServer.on('close', (req, socket, head) => {
108✔
57
    socket.on('error', (error) => {
4✔
58
      debug('Socket error in close event: \n%O', error);
×
59
    });
60
  });
61

62
  // https://github.com/webpack/webpack-dev-server/issues/1642#issuecomment-1103136590
63
  proxyServer.on('econnreset', (error, req, res, target) => {
108✔
NEW
64
    debug(`httpxy econnreset event: \n%O`, error);
×
65
  });
66
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc