diff --git a/src/lib/freeProxyProviders/proxifly.ts b/src/lib/freeProxyProviders/proxifly.ts index 3d1a9d3026..00b4826367 100644 --- a/src/lib/freeProxyProviders/proxifly.ts +++ b/src/lib/freeProxyProviders/proxifly.ts @@ -97,7 +97,7 @@ export class ProxiflyProvider implements FreeProxyProvider { requested += proxies.length; for (const p of proxies) { - if (!p.ip || !p.port) continue; + if (!p || !p.ip || !p.port) continue; if (isPrivateHost(p.ip)) { errors.push(`Proxifly: skipped private/loopback host ${p.ip}`); continue; diff --git a/tests/unit/free-proxy-providers.test.ts b/tests/unit/free-proxy-providers.test.ts index ac566d289e..d04f84c5b6 100644 --- a/tests/unit/free-proxy-providers.test.ts +++ b/tests/unit/free-proxy-providers.test.ts @@ -181,6 +181,9 @@ test("ProxiflyProvider.sync fetches proxies in API-sized batches", async () => { score: 50 + index, geolocation: { country: "US" }, })); + if (batchIndex === 0) { + body[0] = null as unknown as (typeof body)[number]; + } return new Response(JSON.stringify(body), { status: 200, @@ -193,13 +196,13 @@ test("ProxiflyProvider.sync fetches proxies in API-sized batches", async () => { const result = await p.sync(); assert.deepEqual(requestedQuantities, ["20", "5"]); - assert.equal(result.fetched, 25); - assert.equal(result.added, 25); + assert.equal(result.fetched, 24); + assert.equal(result.added, 24); assert.equal(result.updated, 0); assert.deepEqual(result.errors, []); const items = await p.list({ limit: 30 }); - assert.equal(items.length, 25); + assert.equal(items.length, 24); assert.ok(items.every((item) => item.source === "proxifly")); } finally { globalThis.fetch = originalFetch;