Skip to content

Commit 95afeed

Browse files
committed
finished migrating the entire frickin' test suite!!
1 parent 84f02fa commit 95afeed

File tree

6 files changed

+1110
-1064
lines changed

6 files changed

+1110
-1064
lines changed

lib/http-proxy/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
2727
export type ProxyTargetUrl = URL | string;
2828

2929
export interface ServerOptions {
30-
// NOTE: `options.target and `options.forward` cannot be both missing.
30+
// NOTE: `options.target and `options.forward` cannot be both missing when the
31+
// actually proxying is called. However, they can be missing when creating the
32+
// proxy server in the first place! E.g., you could make a proxy server P with
33+
// no options, then use P.web(req,res, {target:...}).
3134
// URL string to be parsed with the url module.
3235
target?: ProxyTarget;
3336
// URL string to be parsed with the url module or a URL object.

lib/http-proxy/passes/ws-incoming.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ export function stream(
211211
} else {
212212
server.emit("error", err, req, socket);
213213
}
214-
socket.end();
214+
// I changed this from "socket.end()" which is what node-http-proxy does to destroySoon() due to getting
215+
// the unit test "should close client socket if upstream is closed before upgrade" from lib/http-proxy.test.ts
216+
// to work. Just doing socket.end() leaves things half open for a while if proxySocket errors out,
217+
// which may be another leak type situation and definitely doesn't work for unit testing.
218+
socket.destroySoon();
215219
}
216220

217221
proxyReq.end();

0 commit comments

Comments
 (0)