@@ -78,15 +78,13 @@ export class Connection extends EventEmitter {
7878 toImpl : ( ( client : ChannelOwner ) => any ) | undefined ;
7979 private _tracingCount = 0 ;
8080 readonly _instrumentation : ClientInstrumentation ;
81- readonly platform : Platform ;
8281 // Used from @playwright /test fixtures -> TODO remove?
8382 readonly headers : HeadersArray ;
8483
8584 constructor ( platform : Platform , localUtils ?: LocalUtils , instrumentation ?: ClientInstrumentation , headers : HeadersArray = [ ] ) {
86- super ( ) ;
85+ super ( platform ) ;
8786 this . _instrumentation = instrumentation || createInstrumentation ( ) ;
8887 this . _localUtils = localUtils ;
89- this . platform = platform ;
9088 this . _rootObject = new Root ( this ) ;
9189 this . headers = headers ;
9290 }
@@ -136,17 +134,17 @@ export class Connection extends EventEmitter {
136134 const type = object . _type ;
137135 const id = ++ this . _lastId ;
138136 const message = { id, guid, method, params } ;
139- if ( this . platform . isLogEnabled ( 'channel' ) ) {
137+ if ( this . _platform . isLogEnabled ( 'channel' ) ) {
140138 // Do not include metadata in debug logs to avoid noise.
141- this . platform . log ( 'channel' , 'SEND> ' + JSON . stringify ( message ) ) ;
139+ this . _platform . log ( 'channel' , 'SEND> ' + JSON . stringify ( message ) ) ;
142140 }
143141 const location = frames [ 0 ] ? { file : frames [ 0 ] . file , line : frames [ 0 ] . line , column : frames [ 0 ] . column } : undefined ;
144142 const metadata : channels . Metadata = { apiName, location, internal : ! apiName , stepId } ;
145143 if ( this . _tracingCount && frames && type !== 'LocalUtils' )
146144 this . _localUtils ?. addStackToTracingNoReply ( { callData : { stack : frames , id } } ) . catch ( ( ) => { } ) ;
147145 // We need to exit zones before calling into the server, otherwise
148146 // when we receive events from the server, we would be in an API zone.
149- this . platform . zones . empty . run ( ( ) => this . onmessage ( { ...message , metadata } ) ) ;
147+ this . _platform . zones . empty . run ( ( ) => this . onmessage ( { ...message , metadata } ) ) ;
150148 return await new Promise ( ( resolve , reject ) => this . _callbacks . set ( id , { resolve, reject, apiName, type, method } ) ) ;
151149 }
152150
@@ -156,15 +154,15 @@ export class Connection extends EventEmitter {
156154
157155 const { id, guid, method, params, result, error, log } = message as any ;
158156 if ( id ) {
159- if ( this . platform . isLogEnabled ( 'channel' ) )
160- this . platform . log ( 'channel' , '<RECV ' + JSON . stringify ( message ) ) ;
157+ if ( this . _platform . isLogEnabled ( 'channel' ) )
158+ this . _platform . log ( 'channel' , '<RECV ' + JSON . stringify ( message ) ) ;
161159 const callback = this . _callbacks . get ( id ) ;
162160 if ( ! callback )
163161 throw new Error ( `Cannot find command to respond: ${ id } ` ) ;
164162 this . _callbacks . delete ( id ) ;
165163 if ( error && ! result ) {
166164 const parsedError = parseError ( error ) ;
167- rewriteErrorMessage ( parsedError , parsedError . message + formatCallLog ( this . platform , log ) ) ;
165+ rewriteErrorMessage ( parsedError , parsedError . message + formatCallLog ( this . _platform , log ) ) ;
168166 callback . reject ( parsedError ) ;
169167 } else {
170168 const validator = findValidator ( callback . type , callback . method , 'Result' ) ;
@@ -173,8 +171,8 @@ export class Connection extends EventEmitter {
173171 return ;
174172 }
175173
176- if ( this . platform . isLogEnabled ( 'channel' ) )
177- this . platform . log ( 'channel' , '<EVENT ' + JSON . stringify ( message ) ) ;
174+ if ( this . _platform . isLogEnabled ( 'channel' ) )
175+ this . _platform . log ( 'channel' , '<EVENT ' + JSON . stringify ( message ) ) ;
178176 if ( method === '__create__' ) {
179177 this . _createRemoteObject ( guid , params . type , params . guid , params . initializer ) ;
180178 return ;
0 commit comments