File tree Expand file tree Collapse file tree 5 files changed +187
-138
lines changed Expand file tree Collapse file tree 5 files changed +187
-138
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import type { QUICConfig } from './config';
44import type QUICConnectionMap from './QUICConnectionMap' ;
55import Logger from '@matrixai/logger' ;
66import { CreateDestroy , ready } from '@matrixai/async-init/dist/CreateDestroy' ;
7- import { running } from '@matrixai/async-init' ;
7+ import { destroyed , running } from '@matrixai/async-init' ;
88import { quiche } from './native' ;
99import * as utils from './utils' ;
1010import * as errors from './errors' ;
@@ -162,22 +162,23 @@ class QUICClient extends EventTarget {
162162 // Console.error(e);
163163 logger . debug ( `Is shared?: ${ isSocketShared } ` ) ;
164164 // Waiting for connection to destroy
165- const destroyedProm = utils . promise < void > ( ) ;
166- connection . addEventListener (
167- 'destroy' ,
168- ( ) => {
169- destroyedProm . resolveP ( ) ;
170- } ,
171- {
172- once : true ,
173- } ,
174- ) ;
175- await destroyedProm . p ;
165+ if ( connection [ destroyed ] === false ) {
166+ const destroyedProm = utils . promise < void > ( ) ;
167+ connection . addEventListener (
168+ 'destroy' ,
169+ ( ) => {
170+ destroyedProm . resolveP ( ) ;
171+ } ,
172+ {
173+ once : true ,
174+ } ,
175+ ) ;
176+ await destroyedProm . p ;
177+ }
176178 if ( ! isSocketShared ) {
177179 // Stop our own socket
178180 await socket . stop ( ) ;
179181 }
180- // Wrapping error to contain both stack traces
181182 throw e ;
182183 }
183184
You can’t perform that action at this time.
0 commit comments