@@ -28,11 +28,11 @@ import QUICConnection from './QUICConnection';
2828import QUICConnectionId from './QUICConnectionId' ;
2929
3030/**
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.
3333 *
3434 * Use the same event names.
35- * However it needs to bubble up.
35+ * However, it needs to bubble up.
3636 * And the right target needs to be used.
3737 *
3838 * Events:
@@ -63,7 +63,7 @@ class QUICClient extends EventTarget {
6363 * @param opts
6464 * @param opts.host - peer host where `0.0.0.0` becomes `127.0.0.1` and `::` becomes `::1`
6565 * @param opts.port
66- * @param opts.localHost - defaults to `::` (dualstack )
66+ * @param opts.localHost - defaults to `::` (dual-stack )
6767 * @param opts.localPort - defaults 0
6868 * @param opts.crypto - client only needs the ability to generate random bytes
6969 * @param opts.config - optional config
@@ -140,7 +140,7 @@ class QUICClient extends EventTarget {
140140 await crypto . ops . randomBytes ( scidBuffer ) ;
141141 const scid = new QUICConnectionId ( scidBuffer ) ;
142142 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
144144 // as a target host, so we need to resolve it to a non-zero IP
145145 // in this case, 0.0.0.0 is resolved to 127.0.0.1 and :: and ::0 is
146146 // resolved to ::1
@@ -227,7 +227,7 @@ class QUICClient extends EventTarget {
227227 try {
228228 await Promise . race ( [ connectionProm , socketErrorP ] ) ;
229229 } 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
231231 abortController . abort ( e ) ;
232232 if ( ! isSocketShared ) {
233233 // Stop is idempotent
@@ -254,13 +254,13 @@ class QUICClient extends EventTarget {
254254 /**
255255 * This must not throw any exceptions.
256256 */
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 ) {
259259 // QUIC socket errors are re-emitted but a destroy takes place
260260 this . dispatchEvent (
261261 new events . QUICClientErrorEvent ( {
262262 detail : new errors . ErrorQUICClient ( 'Socket error' , {
263- cause : e . detail ,
263+ cause : event . detail ,
264264 } ) ,
265265 } ) ,
266266 ) ;
@@ -276,7 +276,7 @@ class QUICClient extends EventTarget {
276276 } ) ,
277277 ) ;
278278 }
279- } else if ( e instanceof events . QUICSocketStopEvent ) {
279+ } else if ( event instanceof events . QUICSocketStopEvent ) {
280280 // If a QUIC socket stopped, we immediately destroy
281281 // However, the stop will have its own constraints
282282 try {
@@ -292,21 +292,21 @@ class QUICClient extends EventTarget {
292292 ) ;
293293 }
294294 } else {
295- this . dispatchEvent ( e ) ;
295+ this . dispatchEvent ( event ) ;
296296 }
297297 } ;
298298
299299 /**
300300 * This must not throw any exceptions.
301301 */
302302 protected handleQUICConnectionEvents = async (
303- e : events . QUICConnectionEvent ,
303+ event : events . QUICConnectionEvent ,
304304 ) => {
305- if ( e instanceof events . QUICConnectionErrorEvent ) {
305+ if ( event instanceof events . QUICConnectionErrorEvent ) {
306306 this . dispatchEvent (
307307 new events . QUICClientErrorEvent ( {
308308 detail : new errors . ErrorQUICClient ( 'Connection error' , {
309- cause : e . detail ,
309+ cause : event . detail ,
310310 } ) ,
311311 } ) ,
312312 ) ;
@@ -322,7 +322,7 @@ class QUICClient extends EventTarget {
322322 } ) ,
323323 ) ;
324324 }
325- } else if ( e instanceof events . QUICConnectionStopEvent ) {
325+ } else if ( event instanceof events . QUICConnectionStopEvent ) {
326326 try {
327327 // Force destroy means don't destroy gracefully
328328 await this . destroy ( {
@@ -335,13 +335,14 @@ class QUICClient extends EventTarget {
335335 } ) ,
336336 ) ;
337337 }
338- }
339- if ( e instanceof events . QUICConnectionStreamEvent ) {
338+ } else if ( event instanceof events . QUICConnectionStreamEvent ) {
340339 this . dispatchEvent (
341- new events . QUICConnectionStreamEvent ( { detail : e . detail } ) ,
340+ new events . QUICConnectionStreamEvent ( { detail : event . detail } ) ,
342341 ) ;
342+ } else if ( event instanceof events . QUICStreamDestroyEvent ) {
343+ this . dispatchEvent ( new events . QUICStreamDestroyEvent ( ) ) ;
343344 } else {
344- throw Error ( 'TMP MUST RETHROW EVENTS' ) ;
345+ utils . never ( ) ;
345346 }
346347 } ;
347348
0 commit comments