@@ -6,6 +6,7 @@ const getFunctionArguments = require('fn-args')
6
6
const deepClone = require ( 'lodash.clonedeep' )
7
7
const { convertColorToRGBA, isColorProperty } = require ( './colorUtils' )
8
8
const Fuse = require ( 'fuse.js' )
9
+ const { spawnSync } = require ( 'child_process' )
9
10
10
11
function deepMerge ( target , source ) {
11
12
const merge = require ( 'lodash.merge' )
@@ -192,19 +193,20 @@ module.exports.test = {
192
193
return function ( key ) {
193
194
if ( ! fs . existsSync ( dataFile ) ) {
194
195
// Increase wait time for CI environments where form submission may be slower
195
- const waitTime = process . env . CI ? 15 * 1000 : 1 * 1000 // 15 seconds in CI, 1 second otherwise
196
- const pollInterval = 100 // Check every 100ms
196
+ const waitTime = process . env . CI ? 30 * 1000 : 1 * 1000 // 30 seconds in CI, 1 second otherwise
197
+ const pollInterval = 200 // Check every 200ms
197
198
const startTime = new Date ( ) . getTime ( )
198
199
199
- // Poll for file existence instead of busy waiting
200
+ // Poll for file existence using proper sleep mechanism
200
201
while ( new Date ( ) . getTime ( ) - startTime < waitTime ) {
201
202
if ( fs . existsSync ( dataFile ) ) {
202
203
break
203
204
}
204
- // Sleep for pollInterval milliseconds
205
- const start = new Date ( ) . getTime ( )
206
- while ( new Date ( ) . getTime ( ) - start < pollInterval ) {
207
- // Small busy wait for polling interval
205
+ // Use spawnSync to create a proper non-CPU-intensive delay
206
+ if ( os . platform ( ) === 'win32' ) {
207
+ spawnSync ( 'ping' , [ '-n' , '1' , '-w' , pollInterval . toString ( ) , '127.0.0.1' ] , { stdio : 'ignore' } )
208
+ } else {
209
+ spawnSync ( 'sleep' , [ ( pollInterval / 1000 ) . toString ( ) ] , { stdio : 'ignore' } )
208
210
}
209
211
}
210
212
}
0 commit comments