@fanboynz/network-scanner 1.0.92 → 1.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/nwss.js +37 -8
  2. package/package.json +1 -1
package/nwss.js CHANGED
@@ -1,4 +1,4 @@
1
- // === Network scanner script (nwss.js) v1.0.91 ===
1
+ // === Network scanner script (nwss.js) v1.0.94 ===
2
2
 
3
3
  // puppeteer for browser automation, fs for file system operations, psl for domain parsing.
4
4
  // const pLimit = require('p-limit'); // Will be dynamically imported
@@ -125,7 +125,7 @@ const { navigateWithRedirectHandling, handleRedirectTimeout } = require('./lib/r
125
125
  const { monitorBrowserHealth, isBrowserHealthy, isQuicklyResponsive } = require('./lib/browserhealth');
126
126
 
127
127
  // --- Script Configuration & Constants ---
128
- const VERSION = '1.0.91'; // Script version
128
+ const VERSION = '1.0.94'; // Script version
129
129
 
130
130
  // get startTime
131
131
  const startTime = Date.now();
@@ -2950,15 +2950,44 @@ function setupFrameHandling(page, forceDebug) {
2950
2950
  }
2951
2951
  }
2952
2952
 
2953
- if (useForceReload) {
2954
- // Force reload: disable cache, reload, re-enable cache
2953
+ let reloadSuccess = false;
2954
+
2955
+ if (useForceReload && !reloadSuccess) {
2956
+ // Attempt force reload: disable cache, reload, re-enable cache
2955
2957
  try {
2956
- await page.setCacheEnabled(false);
2957
- await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 12000) });
2958
- await page.setCacheEnabled(true);
2958
+ // Add timeout protection for setCacheEnabled operations
2959
+ await Promise.race([
2960
+ page.setCacheEnabled(false),
2961
+ new Promise((_, reject) =>
2962
+ setTimeout(() => reject(new Error('setCacheEnabled(false) timeout')), 5000)
2963
+ )
2964
+ ]);
2965
+
2966
+ await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 12000) });
2967
+
2968
+ await Promise.race([
2969
+ page.setCacheEnabled(true),
2970
+ new Promise((_, reject) =>
2971
+ setTimeout(() => reject(new Error('setCacheEnabled(true) timeout')), 5000)
2972
+ )
2973
+ ]);
2974
+
2975
+ reloadSuccess = true;
2959
2976
  if (forceDebug) console.log(formatLogMessage('debug', `Force reload #${i} completed for ${currentUrl}`));
2977
+
2960
2978
  } catch (forceReloadErr) {
2961
- console.warn(messageColors.warn(`[force reload #${i} failed] ${currentUrl}: ${forceReloadErr.message}`));
2979
+ console.warn(messageColors.warn(`[force reload #${i} failed] ${currentUrl}: ${forceReloadErr.message} - falling back to standard reload`));
2980
+ reloadSuccess = false; // Ensure we try standard reload
2981
+ }
2982
+ }
2983
+
2984
+ // Fallback to standard reload if force reload failed or wasn't attempted
2985
+ if (!reloadSuccess) {
2986
+ try {
2987
+ await page.reload({ waitUntil: 'domcontentloaded', timeout: Math.min(timeout, 15000) });
2988
+ if (forceDebug) console.log(formatLogMessage('debug', `Standard reload #${i} completed for ${currentUrl}`));
2989
+ } catch (standardReloadErr) {
2990
+ console.warn(messageColors.warn(`[standard reload #${i} failed] ${currentUrl}: ${standardReloadErr.message}`));
2962
2991
  }
2963
2992
  } else {
2964
2993
  // Regular reload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanboynz/network-scanner",
3
- "version": "1.0.92",
3
+ "version": "1.0.94",
4
4
  "description": "A Puppeteer-based network scanner for analyzing web traffic, generating adblock filter rules, and identifying third-party requests. Features include fingerprint spoofing, Cloudflare bypass, content analysis with curl/grep, and multiple output formats.",
5
5
  "main": "nwss.js",
6
6
  "scripts": {