@@ -126,6 +126,14 @@ class Http2Transport implements Transport {
126126 */
127127 private remoteName : string | null
128128 ) {
129+ /* Populate subchannelAddressString and channelzRef before doing anything
130+ * else, because they are used in the trace methods. */
131+ this . subchannelAddressString = subchannelAddressToString ( subchannelAddress ) ;
132+
133+ if ( options [ 'grpc.enable_channelz' ] === 0 ) {
134+ this . channelzEnabled = false ;
135+ }
136+ this . channelzRef = registerChannelzSocket ( this . subchannelAddressString , ( ) => this . getChannelzInfo ( ) , this . channelzEnabled ) ;
129137 // Build user-agent string.
130138 this . userAgent = [
131139 options [ 'grpc.primary_user_agent' ] ,
@@ -147,16 +155,6 @@ class Http2Transport implements Transport {
147155 } else {
148156 this . keepaliveWithoutCalls = false ;
149157 }
150- if ( this . keepaliveWithoutCalls ) {
151- this . maybeStartKeepalivePingTimer ( ) ;
152- }
153-
154- this . subchannelAddressString = subchannelAddressToString ( subchannelAddress ) ;
155-
156- if ( options [ 'grpc.enable_channelz' ] === 0 ) {
157- this . channelzEnabled = false ;
158- }
159- this . channelzRef = registerChannelzSocket ( this . subchannelAddressString , ( ) => this . getChannelzInfo ( ) , this . channelzEnabled ) ;
160158
161159 session . once ( 'close' , ( ) => {
162160 this . trace ( 'session closed' ) ;
@@ -205,6 +203,11 @@ class Http2Transport implements Transport {
205203 ) ;
206204 } ) ;
207205 }
206+ /* Start the keepalive timer last, because this can trigger trace logs,
207+ * which should only happen after everything else is set up. */
208+ if ( this . keepaliveWithoutCalls ) {
209+ this . maybeStartKeepalivePingTimer ( ) ;
210+ }
208211 }
209212
210213 private getChannelzInfo ( ) : SocketInfo {
0 commit comments