This commit is contained in:
Yanlong Wang 2025-05-08 13:44:59 +08:00
parent dc8781d20c
commit d84ef707df
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -171,6 +171,7 @@ export class GoogleSERP extends AsyncService {
url.searchParams.set('async', getMagicAsyncParam(query.start, ctx.magicId)); url.searchParams.set('async', getMagicAsyncParam(query.start, ctx.magicId));
const t0 = performance.now();
const sideLoaded = await this.sideLoadWithAllocatedProxy(url, { const sideLoaded = await this.sideLoadWithAllocatedProxy(url, {
...opts, ...opts,
allocProxy: opts?.allocProxy || (this.nativeIPHealthy ? 'none' : 'auto'), allocProxy: opts?.allocProxy || (this.nativeIPHealthy ? 'none' : 'auto'),
@ -180,6 +181,7 @@ export class GoogleSERP extends AsyncService {
return Promise.reject(err); return Promise.reject(err);
}); });
const dt = performance.now() - t0;
if ('proxy' in sideLoaded) { if ('proxy' in sideLoaded) {
ctx.proxyUrl = sideLoaded.proxy.href; ctx.proxyUrl = sideLoaded.proxy.href;
@ -187,7 +189,11 @@ export class GoogleSERP extends AsyncService {
} }
if (sideLoaded.status === 200) { if (sideLoaded.status === 200) {
if (dt < 1_700) {
this.contextPool.release(ctx); this.contextPool.release(ctx);
} else {
this.contextPool.destroy(ctx);
}
} else { } else {
if (this.nativeIPHealthy && this.asyncLocalContext.ctx.ctxIsNew) { if (this.nativeIPHealthy && this.asyncLocalContext.ctx.ctxIsNew) {
this.nativeIPBlocked(); this.nativeIPBlocked();