fix(proxy): ignore null Proxifly API entries

This commit is contained in:
Mcdowell Terence
2026-05-31 15:21:21 +02:00
parent 8e9b3e217a
commit c455a360ab
2 changed files with 7 additions and 4 deletions

View File

@@ -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;

View File

@@ -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;