Skip to content

Commit 48d42fb

Browse files
committed
fix: fixed up passing initial packet data to start
1 parent f0455ca commit 48d42fb

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/QUICConnection.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,13 @@ class QUICConnection extends EventTarget {
278278
};
279279
ctx.signal.addEventListener('abort', abortHandler);
280280
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;
285283
// This ensures that TLS has been established and verified on both sides
286284
try {
287285
await Promise.race([
288286
Promise.all([
289-
connection.start(initialData),
287+
connection.start(data),
290288
connection.establishedP,
291289
connection.secureEstablishedP,
292290
]),
@@ -459,20 +457,21 @@ class QUICConnection extends EventTarget {
459457

460458
/**
461459
* 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.
463461
*/
464-
public async start(initialData?: {
465-
data: Uint8Array;
466-
remoteInfo: RemoteInfo;
467-
}): Promise<void> {
462+
public async start(data?: Uint8Array): Promise<void> {
468463
this.logger.info(`Start ${this.constructor.name}`);
469464
// Set the connection up
470465
this.socket.connectionMap.set(this.connectionId, this);
471466
await withF(
472467
[contextsUtils.monitor(this.lockbox, RWLockWriter)],
473468
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+
);
476475
}
477476
await this.send(mon);
478477
},

0 commit comments

Comments
 (0)