Merge pull request #1342 from murgatroid99/grpc-js_proxy_status_fix

grpc-js: Fix status check when connecting to proxy
This commit is contained in:
Michael Lumish 2020-04-09 10:47:07 -07:00 committed by GitHub
commit 4823d97aba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "0.7.7",
"version": "0.7.8",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -58,7 +58,7 @@ function getProxyInfo(): ProxyInfo {
try {
proxyUrl = new URL(proxyEnv);
} catch (e) {
log(LogVerbosity.INFO, `cannot parse value of "${envVar}" env var`);
log(LogVerbosity.ERROR, `cannot parse value of "${envVar}" env var`);
return {};
}
if (proxyUrl.protocol !== 'http:') {
@ -145,17 +145,17 @@ export function getProxiedConnection(target: string, subchannelAddress: Subchann
request.once('connect', (res, socket, head) => {
request.removeAllListeners();
socket.removeAllListeners();
if (res.statusCode === http.STATUS_CODES.OK) {
if (res.statusCode === 200) {
trace('Successfully connected to ' + subchannelAddress + ' through proxy ' + PROXY_INFO.address);
resolve(socket);
} else {
trace('Failed to connect to ' + subchannelAddress + ' through proxy ' + PROXY_INFO.address);
log(LogVerbosity.ERROR, 'Failed to connect to ' + subchannelAddress + ' through proxy ' + PROXY_INFO.address);
reject();
}
});
request.once('error', (err) => {
request.removeAllListeners();
trace('Failed to connect to proxy ' + PROXY_INFO.address);
log(LogVerbosity.ERROR, 'Failed to connect to proxy ' + PROXY_INFO.address);
reject();
});
});