@@ -153,6 +153,14 @@ class Http2Transport implements Transport {
153
153
*/
154
154
private remoteName : string | null
155
155
) {
156
+ /* Populate subchannelAddressString and channelzRef before doing anything
157
+ * else, because they are used in the trace methods. */
158
+ this . subchannelAddressString = subchannelAddressToString ( subchannelAddress ) ;
159
+
160
+ if ( options [ 'grpc.enable_channelz' ] === 0 ) {
161
+ this . channelzEnabled = false ;
162
+ }
163
+ this . channelzRef = registerChannelzSocket ( this . subchannelAddressString , ( ) => this . getChannelzInfo ( ) , this . channelzEnabled ) ;
156
164
// Build user-agent string.
157
165
this . userAgent = [
158
166
options [ 'grpc.primary_user_agent' ] ,
@@ -174,20 +182,6 @@ class Http2Transport implements Transport {
174
182
} else {
175
183
this . keepaliveWithoutCalls = false ;
176
184
}
177
- if ( this . keepaliveWithoutCalls ) {
178
- this . maybeStartKeepalivePingTimer ( ) ;
179
- }
180
-
181
- this . subchannelAddressString = subchannelAddressToString ( subchannelAddress ) ;
182
-
183
- if ( options [ 'grpc.enable_channelz' ] === 0 ) {
184
- this . channelzEnabled = false ;
185
- }
186
- this . channelzRef = registerChannelzSocket (
187
- this . subchannelAddressString ,
188
- ( ) => this . getChannelzInfo ( ) ,
189
- this . channelzEnabled
190
- ) ;
191
185
192
186
session . once ( 'close' , ( ) => {
193
187
this . trace ( 'session closed' ) ;
@@ -233,6 +227,11 @@ class Http2Transport implements Transport {
233
227
) ;
234
228
} ) ;
235
229
}
230
+ /* Start the keepalive timer last, because this can trigger trace logs,
231
+ * which should only happen after everything else is set up. */
232
+ if ( this . keepaliveWithoutCalls ) {
233
+ this . maybeStartKeepalivePingTimer ( ) ;
234
+ }
236
235
}
237
236
238
237
private getChannelzInfo ( ) : SocketInfo {
0 commit comments