@@ -6,6 +6,7 @@ const getFunctionArguments = require('fn-args')
66const deepClone = require ( 'lodash.clonedeep' )
77const { convertColorToRGBA, isColorProperty } = require ( './colorUtils' )
88const Fuse = require ( 'fuse.js' )
9+ const { spawnSync } = require ( 'child_process' )
910
1011function deepMerge ( target , source ) {
1112 const merge = require ( 'lodash.merge' )
@@ -192,19 +193,20 @@ module.exports.test = {
192193 return function ( key ) {
193194 if ( ! fs . existsSync ( dataFile ) ) {
194195 // 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
197198 const startTime = new Date ( ) . getTime ( )
198199
199- // Poll for file existence instead of busy waiting
200+ // Poll for file existence using proper sleep mechanism
200201 while ( new Date ( ) . getTime ( ) - startTime < waitTime ) {
201202 if ( fs . existsSync ( dataFile ) ) {
202203 break
203204 }
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' } )
208210 }
209211 }
210212 }
0 commit comments