@@ -28,11 +28,11 @@ import QUICConnection from './QUICConnection';
28
28
import QUICConnectionId from './QUICConnectionId' ;
29
29
30
30
/**
31
- * You must provide a error handler `addEventListener('error')`.
32
- * Otherwise errors will just be ignored.
31
+ * You must provide an error handler `addEventListener('error')`.
32
+ * Otherwise, errors will just be ignored.
33
33
*
34
34
* Use the same event names.
35
- * However it needs to bubble up.
35
+ * However, it needs to bubble up.
36
36
* And the right target needs to be used.
37
37
*
38
38
* Events:
@@ -63,7 +63,7 @@ class QUICClient extends EventTarget {
63
63
* @param opts
64
64
* @param opts.host - peer host where `0.0.0.0` becomes `127.0.0.1` and `::` becomes `::1`
65
65
* @param opts.port
66
- * @param opts.localHost - defaults to `::` (dualstack )
66
+ * @param opts.localHost - defaults to `::` (dual-stack )
67
67
* @param opts.localPort - defaults 0
68
68
* @param opts.crypto - client only needs the ability to generate random bytes
69
69
* @param opts.config - optional config
@@ -140,7 +140,7 @@ class QUICClient extends EventTarget {
140
140
await crypto . ops . randomBytes ( scidBuffer ) ;
141
141
const scid = new QUICConnectionId ( scidBuffer ) ;
142
142
let [ host_ ] = await utils . resolveHost ( host , resolveHostname ) ;
143
- // If the target host is in fact an zero IP, it cannot be used
143
+ // If the target host is in fact a zero IP, it cannot be used
144
144
// as a target host, so we need to resolve it to a non-zero IP
145
145
// in this case, 0.0.0.0 is resolved to 127.0.0.1 and :: and ::0 is
146
146
// resolved to ::1
@@ -227,7 +227,7 @@ class QUICClient extends EventTarget {
227
227
try {
228
228
await Promise . race ( [ connectionProm , socketErrorP ] ) ;
229
229
} catch ( e ) {
230
- // In case the `connection.start` is on-going , we need to abort it
230
+ // In case the `connection.start` is ongoing , we need to abort it
231
231
abortController . abort ( e ) ;
232
232
if ( ! isSocketShared ) {
233
233
// Stop is idempotent
@@ -254,13 +254,13 @@ class QUICClient extends EventTarget {
254
254
/**
255
255
* This must not throw any exceptions.
256
256
*/
257
- protected handleQUICSocketEvents = async ( e : events . QUICSocketEvent ) => {
258
- if ( e instanceof events . QUICSocketErrorEvent ) {
257
+ protected handleQUICSocketEvents = async ( event : events . QUICSocketEvent ) => {
258
+ if ( event instanceof events . QUICSocketErrorEvent ) {
259
259
// QUIC socket errors are re-emitted but a destroy takes place
260
260
this . dispatchEvent (
261
261
new events . QUICClientErrorEvent ( {
262
262
detail : new errors . ErrorQUICClient ( 'Socket error' , {
263
- cause : e . detail ,
263
+ cause : event . detail ,
264
264
} ) ,
265
265
} ) ,
266
266
) ;
@@ -276,7 +276,7 @@ class QUICClient extends EventTarget {
276
276
} ) ,
277
277
) ;
278
278
}
279
- } else if ( e instanceof events . QUICSocketStopEvent ) {
279
+ } else if ( event instanceof events . QUICSocketStopEvent ) {
280
280
// If a QUIC socket stopped, we immediately destroy
281
281
// However, the stop will have its own constraints
282
282
try {
@@ -292,21 +292,21 @@ class QUICClient extends EventTarget {
292
292
) ;
293
293
}
294
294
} else {
295
- this . dispatchEvent ( e ) ;
295
+ this . dispatchEvent ( event ) ;
296
296
}
297
297
} ;
298
298
299
299
/**
300
300
* This must not throw any exceptions.
301
301
*/
302
302
protected handleQUICConnectionEvents = async (
303
- e : events . QUICConnectionEvent ,
303
+ event : events . QUICConnectionEvent ,
304
304
) => {
305
- if ( e instanceof events . QUICConnectionErrorEvent ) {
305
+ if ( event instanceof events . QUICConnectionErrorEvent ) {
306
306
this . dispatchEvent (
307
307
new events . QUICClientErrorEvent ( {
308
308
detail : new errors . ErrorQUICClient ( 'Connection error' , {
309
- cause : e . detail ,
309
+ cause : event . detail ,
310
310
} ) ,
311
311
} ) ,
312
312
) ;
@@ -322,7 +322,7 @@ class QUICClient extends EventTarget {
322
322
} ) ,
323
323
) ;
324
324
}
325
- } else if ( e instanceof events . QUICConnectionStopEvent ) {
325
+ } else if ( event instanceof events . QUICConnectionStopEvent ) {
326
326
try {
327
327
// Force destroy means don't destroy gracefully
328
328
await this . destroy ( {
@@ -335,13 +335,14 @@ class QUICClient extends EventTarget {
335
335
} ) ,
336
336
) ;
337
337
}
338
- }
339
- if ( e instanceof events . QUICConnectionStreamEvent ) {
338
+ } else if ( event instanceof events . QUICConnectionStreamEvent ) {
340
339
this . dispatchEvent (
341
- new events . QUICConnectionStreamEvent ( { detail : e . detail } ) ,
340
+ new events . QUICConnectionStreamEvent ( { detail : event . detail } ) ,
342
341
) ;
342
+ } else if ( event instanceof events . QUICStreamDestroyEvent ) {
343
+ this . dispatchEvent ( new events . QUICStreamDestroyEvent ( ) ) ;
343
344
} else {
344
- throw Error ( 'TMP MUST RETHROW EVENTS' ) ;
345
+ utils . never ( ) ;
345
346
}
346
347
} ;
347
348
0 commit comments