Skip to content

Commit

Permalink
Merge pull request #1954 from murgatroid99/grpc-js_channelz_local_add…
Browse files Browse the repository at this point in the history
…ress_null_1.4.x

grpc-js: Handle undefined `socket.localAddress` (1.4.x)
  • Loading branch information
murgatroid99 authored Oct 26, 2021
2 parents c61b969 + 91ae2b4 commit 78466ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/grpc-js/src/channelz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export interface TlsInfo {
}

export interface SocketInfo {
localAddress: SubchannelAddress;
localAddress: SubchannelAddress | null;
remoteAddress: SubchannelAddress | null;
security: TlsInfo | null;
remoteName: string | null;
Expand Down Expand Up @@ -629,7 +629,7 @@ function GetSocket(call: ServerUnaryCall<GetSocketRequest__Output, GetSocketResp
} : null;
const socketMessage: SocketMessage = {
ref: socketRefToMessage(socketEntry.ref),
local: subchannelAddressToAddressMessage(resolvedInfo.localAddress),
local: resolvedInfo.localAddress ? subchannelAddressToAddressMessage(resolvedInfo.localAddress) : null,
remote: resolvedInfo.remoteAddress ? subchannelAddressToAddressMessage(resolvedInfo.remoteAddress) : null,
remote_name: resolvedInfo.remoteName ?? undefined,
security: securityMessage,
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class Server {
const sessionInfo = this.sessions.get(session)!;
const sessionSocket = session.socket;
const remoteAddress = sessionSocket.remoteAddress ? stringToSubchannelAddress(sessionSocket.remoteAddress, sessionSocket.remotePort) : null;
const localAddress = stringToSubchannelAddress(sessionSocket.localAddress, sessionSocket.localPort);
const localAddress = sessionSocket.localAddress ? stringToSubchannelAddress(sessionSocket.localAddress!, sessionSocket.localPort) : null;
let tlsInfo: TlsInfo | null;
if (session.encrypted) {
const tlsSocket: TLSSocket = sessionSocket as TLSSocket;
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js/src/subchannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class Subchannel {
}
const sessionSocket = this.session.socket;
const remoteAddress = sessionSocket.remoteAddress ? stringToSubchannelAddress(sessionSocket.remoteAddress, sessionSocket.remotePort) : null;
const localAddress = stringToSubchannelAddress(sessionSocket.localAddress, sessionSocket.localPort);
const localAddress = sessionSocket.localAddress ? stringToSubchannelAddress(sessionSocket.localAddress, sessionSocket.localPort) : null;
let tlsInfo: TlsInfo | null;
if (this.session.encrypted) {
const tlsSocket: TLSSocket = sessionSocket as TLSSocket;
Expand Down

0 comments on commit 78466ac

Please sign in to comment.