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';
4
4
import type QUICConnectionMap from './QUICConnectionMap' ;
5
5
import Logger from '@matrixai/logger' ;
6
6
import { CreateDestroy , ready } from '@matrixai/async-init/dist/CreateDestroy' ;
7
- import { running } from '@matrixai/async-init' ;
7
+ import { destroyed , running } from '@matrixai/async-init' ;
8
8
import { quiche } from './native' ;
9
9
import * as utils from './utils' ;
10
10
import * as errors from './errors' ;
@@ -162,22 +162,23 @@ class QUICClient extends EventTarget {
162
162
// Console.error(e);
163
163
logger . debug ( `Is shared?: ${ isSocketShared } ` ) ;
164
164
// 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
+ }
176
178
if ( ! isSocketShared ) {
177
179
// Stop our own socket
178
180
await socket . stop ( ) ;
179
181
}
180
- // Wrapping error to contain both stack traces
181
182
throw e ;
182
183
}
183
184
You can’t perform that action at this time.
0 commit comments