@@ -192,13 +192,12 @@ module.exports.test = {
192
192
submittedData ( dataFile ) {
193
193
return function ( key ) {
194
194
if ( ! fs . existsSync ( dataFile ) ) {
195
- // Increase wait time for CI environments where form submission may be slower
196
- const waitTime = process . env . CI ? 45 * 1000 : 1 * 1000 // 45 seconds in CI, 1 second otherwise
197
- const pollInterval = 500 // Check every 500ms to reduce load
195
+ // Reduce wait time while maintaining reliability across different environments
196
+ const waitTime = process . env . CI ? 30 * 1000 : 1 * 1000 // 30 seconds in CI, 1 second otherwise
197
+ const pollInterval = 250 // Check every 250ms for faster detection
198
198
const startTime = new Date ( ) . getTime ( )
199
199
200
- // Poll for file existence with exponential backoff-style intervals
201
- let currentInterval = pollInterval
200
+ // Poll for file existence with optimized intervals
202
201
while ( new Date ( ) . getTime ( ) - startTime < waitTime ) {
203
202
if ( fs . existsSync ( dataFile ) ) {
204
203
break
@@ -208,24 +207,21 @@ module.exports.test = {
208
207
try {
209
208
if ( os . platform ( ) === 'win32' ) {
210
209
// Use timeout command which is more reliable than ping
211
- spawnSync ( 'timeout' , [ '/t' , Math . ceil ( currentInterval / 1000 ) . toString ( ) ] , { stdio : 'ignore' } )
210
+ spawnSync ( 'timeout' , [ '/t' , '1' ] , { stdio : 'ignore' } )
212
211
} else {
213
212
// Use sleep with fractional seconds for better precision
214
- spawnSync ( 'sleep' , [ ( currentInterval / 1000 ) . toString ( ) ] , { stdio : 'ignore' } )
213
+ spawnSync ( 'sleep' , [ ( pollInterval / 1000 ) . toString ( ) ] , { stdio : 'ignore' } )
215
214
}
216
215
} catch ( err ) {
217
216
// Fallback to setTimeout-based delay if system commands fail
218
- const end = new Date ( ) . getTime ( ) + currentInterval
217
+ const end = new Date ( ) . getTime ( ) + pollInterval
219
218
while ( new Date ( ) . getTime ( ) < end ) {
220
219
// Small yield to prevent complete CPU lock
221
220
if ( new Date ( ) . getTime ( ) % 10 === 0 ) {
222
221
process . nextTick ( ( ) => { } )
223
222
}
224
223
}
225
224
}
226
-
227
- // Gradually increase interval to reduce polling frequency over time
228
- currentInterval = Math . min ( currentInterval * 1.2 , 2000 )
229
225
}
230
226
}
231
227
if ( ! fs . existsSync ( dataFile ) ) {
0 commit comments