@@ -278,15 +278,13 @@ class QUICConnection extends EventTarget {
278
278
} ;
279
279
ctx . signal . addEventListener ( 'abort' , abortHandler ) ;
280
280
const connection = new this ( args ) ;
281
- const initialData =
282
- args . type === 'server'
283
- ? { data : args . data , remoteInfo : args . remoteInfo }
284
- : undefined ;
281
+ // If it's a server connection we want to pass the initial packet
282
+ const data = args . type === 'server' ? args . data : undefined ;
285
283
// This ensures that TLS has been established and verified on both sides
286
284
try {
287
285
await Promise . race ( [
288
286
Promise . all ( [
289
- connection . start ( initialData ) ,
287
+ connection . start ( data ) ,
290
288
connection . establishedP ,
291
289
connection . secureEstablishedP ,
292
290
] ) ,
@@ -459,20 +457,21 @@ class QUICConnection extends EventTarget {
459
457
460
458
/**
461
459
* This will set up the connection initiate sending
462
- * @param initialData - If the connection is server initiated then the data that initiated it needs to be provided here
460
+ * @param data - the initial packet that triggered the creation of the connection.
463
461
*/
464
- public async start ( initialData ?: {
465
- data : Uint8Array ;
466
- remoteInfo : RemoteInfo ;
467
- } ) : Promise < void > {
462
+ public async start ( data ?: Uint8Array ) : Promise < void > {
468
463
this . logger . info ( `Start ${ this . constructor . name } ` ) ;
469
464
// Set the connection up
470
465
this . socket . connectionMap . set ( this . connectionId , this ) ;
471
466
await withF (
472
467
[ contextsUtils . monitor ( this . lockbox , RWLockWriter ) ] ,
473
468
async ( [ mon ] ) => {
474
- if ( initialData != null ) {
475
- await this . recv ( initialData . data , initialData . remoteInfo , mon ) ;
469
+ if ( data != null ) {
470
+ await this . recv (
471
+ data ,
472
+ { host : this . _remoteHost , port : this . _remotePort } ,
473
+ mon ,
474
+ ) ;
476
475
}
477
476
await this . send ( mon ) ;
478
477
} ,
0 commit comments