File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
integration-tests/cypress Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ const { DD_HOST_CPU_COUNT } = require('../../packages/dd-trace/src/plugins/util/
65
65
const { ERROR_MESSAGE } = require ( '../../packages/dd-trace/src/constants' )
66
66
const { DD_MAJOR , NODE_MAJOR } = require ( '../../version' )
67
67
68
+ const RECEIVER_STOP_TIMEOUT = 20000
68
69
const version = process . env . CYPRESS_VERSION
69
70
const hookFile = 'dd-trace/loader-hook.mjs'
70
71
const NUM_RETRIES_EFD = 3
@@ -154,9 +155,24 @@ moduleTypes.forEach(({
154
155
receiver = await new FakeCiVisIntake ( ) . start ( )
155
156
} )
156
157
158
+ // Cypress child processes can sometimes hang or take longer to
159
+ // terminate. This can cause `FakeCiVisIntake#stop` to be delayed
160
+ // because there are pending connections.
157
161
afterEach ( async ( ) => {
158
162
childProcess . kill ( )
159
- await receiver . stop ( )
163
+
164
+ // Add timeout to prevent hanging
165
+ const stopPromise = receiver . stop ( )
166
+ const timeoutPromise = new Promise ( ( resolve , reject ) =>
167
+ setTimeout ( ( ) => reject ( new Error ( 'Receiver stop timeout' ) ) , RECEIVER_STOP_TIMEOUT )
168
+ )
169
+
170
+ try {
171
+ await Promise . race ( [ stopPromise , timeoutPromise ] )
172
+ } catch ( error ) {
173
+ // eslint-disable-next-line no-console
174
+ console . warn ( 'Receiver stop timed out:' , error . message )
175
+ }
160
176
} )
161
177
162
178
if ( version === '6.7.0' ) {
You can’t perform that action at this time.
0 commit comments