File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -159,23 +159,28 @@ describe('Connect Tests', function () {
159
159
server . setMessageHandler ( ( ) => null ) ;
160
160
161
161
const cancellationToken = new CancellationToken ( ) ;
162
- setTimeout ( ( ) => cancellationToken . emit ( 'cancel' ) , 500 ) ;
162
+ // Make sure the cancel listener is added before emitting cancel
163
+ cancellationToken . addListener ( 'newListener' , ( ) => {
164
+ process . nextTick ( ( ) => {
165
+ cancellationToken . emit ( 'cancel' ) ;
166
+ } ) ;
167
+ } ) ;
163
168
164
169
const error = await promisify < Connection > ( callback =>
165
170
connect (
166
171
{
167
172
...connectOptions ,
168
173
// Ensure these timeouts do not fire first
169
- socketTimeoutMS : 1000 ,
170
- connectTimeoutMS : 1000 ,
174
+ socketTimeoutMS : 5000 ,
175
+ connectTimeoutMS : 5000 ,
171
176
cancellationToken
172
177
} ,
173
178
//@ts -expect-error: Callbacks do not have mutual exclusion for error/result existence
174
179
callback
175
180
)
176
181
) ( ) . catch ( error => error ) ;
177
182
178
- expect ( error ) . to . match ( / c o n n e c t i o n e s t a b l i s h m e n t w a s c a n c e l l e d / ) ;
183
+ expect ( error , error . stack ) . to . match ( / c o n n e c t i o n e s t a b l i s h m e n t w a s c a n c e l l e d / ) ;
179
184
} ) ;
180
185
} ) ;
181
186
You can’t perform that action at this time.
0 commit comments