channel-worker 2.5.129 → 2.5.130
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.
- package/package.json +1 -1
- package/scripts/lib/warm-web.js +9 -2
package/package.json
CHANGED
package/scripts/lib/warm-web.js
CHANGED
|
@@ -167,15 +167,22 @@ async function visitSite(page, url, log) {
|
|
|
167
167
|
|
|
168
168
|
async function warmWeb({ page, cfg = {}, log }) {
|
|
169
169
|
const out = { ran: false, sites: 0, seconds: 0, last_origin: '' };
|
|
170
|
+
// EVERY exit logs, including the ones that do nothing. A probability branch
|
|
171
|
+
// that stays silent when it skips is indistinguishable from a branch that is
|
|
172
|
+
// never reached: measured 2026-09-22, four sessions in a row rolled a skip
|
|
173
|
+
// (0.4^4 = 2.6%) and the only way to tell bad luck from a dead code path was
|
|
174
|
+
// to re-run the module by hand on each machine. One line is cheaper.
|
|
175
|
+
const say = (m) => { if (typeof log === 'function') log('info', `[warm-web] ${m}`); };
|
|
170
176
|
const prob = cfg.warm_prob ?? 0.6;
|
|
171
|
-
if (!(prob > 0)
|
|
177
|
+
if (!(prob > 0)) { say(`tắt (warm_prob=${prob}) — không lướt web ngoài`); return out; }
|
|
178
|
+
if (!chance(prob)) { say(`bỏ qua lượt này (quay xác suất trượt, warm_prob=${prob})`); return out; }
|
|
172
179
|
|
|
173
180
|
// A MISSING list means "the API is older than this script" → use the built-in
|
|
174
181
|
// one. An EMPTY list means the caller said no sites, so browse none: a config
|
|
175
182
|
// that clears the list must not quietly fall back to six hardcoded domains.
|
|
176
183
|
const pool = (Array.isArray(cfg.warm_sites) ? cfg.warm_sites : DEFAULT_SITES)
|
|
177
184
|
.filter((u) => typeof u === 'string' && /^https?:\/\//i.test(u));
|
|
178
|
-
if (!pool.length) return out;
|
|
185
|
+
if (!pool.length) { say('danh sách site rỗng — không lướt web ngoài'); return out; }
|
|
179
186
|
|
|
180
187
|
const want = randInt(Math.max(1, cfg.warm_sites_min ?? 1), Math.max(1, cfg.warm_sites_max ?? 3));
|
|
181
188
|
const budgetSec = randInt(cfg.warm_sec_min ?? 60, Math.max(cfg.warm_sec_min ?? 60, cfg.warm_sec_max ?? 150));
|