@@ -126,6 +126,14 @@ class Http2Transport implements Transport {
126
126
*/
127
127
private remoteName : string | null
128
128
) {
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 ) ;
129
137
// Build user-agent string.
130
138
this . userAgent = [
131
139
options [ 'grpc.primary_user_agent' ] ,
@@ -147,16 +155,6 @@ class Http2Transport implements Transport {
147
155
} else {
148
156
this . keepaliveWithoutCalls = false ;
149
157
}
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 ) ;
160
158
161
159
session . once ( 'close' , ( ) => {
162
160
this . trace ( 'session closed' ) ;
@@ -205,6 +203,11 @@ class Http2Transport implements Transport {
205
203
) ;
206
204
} ) ;
207
205
}
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
+ }
208
211
}
209
212
210
213
private getChannelzInfo ( ) : SocketInfo {
0 commit comments