node-http-mitm-proxy
node-http-mitm-proxy copied to clipboard
No error when trying to listen on an in-use port
Calling proxy.listen({port:PORT_IN_USE}) where PORT_IN_USE is already being used by another process does not cause any immediate error. The library should throw an error if this is the case.
Nowadays, an error bubbles up when the port is already in use.
However, it is not caught by the callback given to proxy.listen, but rather in proxy.onError. This is somewhat unexpected...
const proxy = new Proxy();
proxy.onError(function (ctx: IContext, err: any) {
// code here is triggered
});
proxy.listen({ port: PORT_IN_USE }, function (err) {
if (err) {
// code here isn't
}
})