@@ -263,19 +263,25 @@ async function fetchFallbackPreview(url: string) {
263263async function validateModuleUrl (
264264 module : ModuleEntry
265265) : Promise < UrlValidationResult > {
266+ logger . info ( `=== DIAGNOSTIC: validateModuleUrl called for ${ module . name } (${ module . url } ) ===` ) ;
267+
266268 try {
269+ logger . info ( `=== DIAGNOSTIC: Making HEAD request to ${ module . url } ===` ) ;
267270 const headResponse = await httpClient . request ( module . url , {
268271 method : "HEAD" ,
269272 redirect : "manual" ,
270273 retries : URL_VALIDATION_RETRY_COUNT ,
271274 retryDelayMs : URL_VALIDATION_RETRY_DELAY_MS
272275 } ) ;
273276
277+ logger . info ( `=== DIAGNOSTIC: HEAD response received: ${ headResponse . status } ${ headResponse . statusText } ===` ) ;
278+
274279 const headSnippet = await readSnippet ( headResponse ) ;
275280 const headStatus = headResponse . status ;
276281 const headStatusText = headResponse . statusText ;
277282
278283 if ( isSuccessStatus ( headStatus ) || isAllowedRedirect ( headStatus ) ) {
284+ logger . info ( `=== DIAGNOSTIC: URL ${ module . url } validated successfully ===` ) ;
279285 return {
280286 module,
281287 statusCode : headStatus ,
@@ -285,6 +291,7 @@ async function validateModuleUrl(
285291 } ;
286292 }
287293
294+ logger . info ( `=== DIAGNOSTIC: HEAD failed with ${ headStatus } , trying fallback GET ===` ) ;
288295 const fallbackPreview = await fetchFallbackPreview ( module . url ) ;
289296 if (
290297 fallbackPreview &&
@@ -323,6 +330,10 @@ async function validateModuleUrl(
323330 } ;
324331 } catch ( error ) {
325332 const message = error instanceof Error ? error . message : String ( error ) ;
333+ logger . error ( `=== DIAGNOSTIC: Exception in validateModuleUrl for ${ module . url } : ${ message } ===` ) ;
334+ if ( error instanceof Error && error . stack ) {
335+ logger . error ( `Stack: ${ error . stack } ` ) ;
336+ }
326337 logger . warn ( `URL ${ module . url } : ${ message } ` ) ;
327338 return {
328339 module,
@@ -343,6 +354,9 @@ async function validateModuleUrls({
343354 limit ?: number ;
344355 urlConcurrency : number ;
345356} ) {
357+ logger . info ( "=== DIAGNOSTIC: validateModuleUrls called ===" ) ;
358+ logger . info ( `Total modules: ${ modules . length } , limit: ${ limit } , concurrency: ${ urlConcurrency } ` ) ;
359+
346360 const total =
347361 typeof limit === "number"
348362 ? Math . min ( limit , modules . length )
@@ -354,13 +368,16 @@ async function validateModuleUrls({
354368 return [ ] ;
355369 }
356370
371+ logger . info ( `=== DIAGNOSTIC: About to validate ${ targets . length } modules ===` ) ;
372+
357373 const results : UrlValidationResult [ ] = new Array ( targets . length ) ;
358374 let nextIndex = 0 ;
359375 let completed = 0 ;
360376
361377 const progressInterval = Math . max ( 10 , Math . ceil ( total / 10 ) ) ;
362378
363379 async function worker ( ) {
380+ logger . info ( "=== DIAGNOSTIC: Worker started ===" ) ;
364381 for ( ; ; ) {
365382 const currentIndex = nextIndex ;
366383 if ( currentIndex >= targets . length ) {
@@ -369,21 +386,38 @@ async function validateModuleUrls({
369386 nextIndex += 1 ;
370387
371388 const module = targets [ currentIndex ] ;
372- const result = await validateModuleUrl ( module ) ;
373-
374- results [ currentIndex ] = result ;
375- completed += 1 ;
389+ logger . info ( `=== DIAGNOSTIC: Validating module ${ currentIndex + 1 } /${ targets . length } : ${ module . name } - ${ module . url } ===` ) ;
390+
391+ try {
392+ const result = await validateModuleUrl ( module ) ;
393+ results [ currentIndex ] = result ;
394+ completed += 1 ;
395+
396+ logger . info ( `=== DIAGNOSTIC: Completed ${ completed } /${ total } ===` ) ;
376397
377- if ( completed % progressInterval === 0 || completed === total ) {
378- logger . info (
379- `Progress: ${ completed } /${ total } URLs validated (concurrency=${ urlConcurrency } )`
380- ) ;
398+ if ( completed % progressInterval === 0 || completed === total ) {
399+ logger . info (
400+ `Progress: ${ completed } /${ total } URLs validated (concurrency=${ urlConcurrency } )`
401+ ) ;
402+ }
403+ } catch ( error ) {
404+ logger . error ( `=== DIAGNOSTIC: Error validating ${ module . name } : ${ error } ===` ) ;
405+ throw error ;
381406 }
382407 }
408+ logger . info ( "=== DIAGNOSTIC: Worker finished ===" ) ;
383409 }
384410
385411 const workerCount = Math . min ( urlConcurrency , targets . length ) ;
386- await Promise . all ( Array . from ( { length : workerCount } , ( ) => worker ( ) ) ) ;
412+ logger . info ( `=== DIAGNOSTIC: Starting ${ workerCount } workers ===` ) ;
413+
414+ try {
415+ await Promise . all ( Array . from ( { length : workerCount } , ( ) => worker ( ) ) ) ;
416+ logger . info ( "=== DIAGNOSTIC: All workers completed successfully ===" ) ;
417+ } catch ( error ) {
418+ logger . error ( `=== DIAGNOSTIC: Worker pool error: ${ error } ===` ) ;
419+ throw error ;
420+ }
387421
388422 return results ;
389423}
0 commit comments