mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-01-11 06:12:19 -06:00
Esse erro acontece porque o Node.js (a partir da versão 18) usa o Undici como implementação nativa de fetch(), e o Undici não aceita mais objetos agent tradicionais (como os criados por https-proxy-agent ou socks-proxy-agent).
Ele espera objetos compatíveis com a interface moderna Dispatcher, que possuem o método dispatch(). Ou seja, o Baileys estava recebendo um tipo de agente incompatível com o novo sistema de rede do Node. Foi criada uma nova função makeProxyAgentUndici() para gerar agentes de proxy compatíveis com o Undici, mantendo a versão antiga (makeProxyAgent()) inalterada para compatibilidade com bibliotecas como Axios. A nova função substitui os antigos HttpsProxyAgent e SocksProxyAgent por ProxyAgent da biblioteca undici, garantindo compatibilidade total com o Baileys e com qualquer uso de fetch() moderno.
This commit is contained in:
@@ -82,7 +82,7 @@ import { createId as cuid } from '@paralleldrive/cuid2';
|
||||
import { Instance, Message } from '@prisma/client';
|
||||
import { createJid } from '@utils/createJid';
|
||||
import { fetchLatestWaWebVersion } from '@utils/fetchLatestWaWebVersion';
|
||||
import { makeProxyAgent } from '@utils/makeProxyAgent';
|
||||
import {makeProxyAgent, makeProxyAgentUndici} from '@utils/makeProxyAgent';
|
||||
import { getOnWhatsappCache, saveOnWhatsappCache } from '@utils/onWhatsappCache';
|
||||
import { status } from '@utils/renderStatus';
|
||||
import { sendTelemetry } from '@utils/sendTelemetry';
|
||||
@@ -594,7 +594,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
const proxyUrls = text.split('\r\n');
|
||||
const rand = Math.floor(Math.random() * Math.floor(proxyUrls.length));
|
||||
const proxyUrl = 'http://' + proxyUrls[rand];
|
||||
options = { agent: makeProxyAgent(proxyUrl), fetchAgent: makeProxyAgent(proxyUrl) };
|
||||
options = { agent: makeProxyAgent(proxyUrl), fetchAgent: makeProxyAgentUndici(proxyUrl) };
|
||||
} catch {
|
||||
this.localProxy.enabled = false;
|
||||
}
|
||||
@@ -607,7 +607,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
username: this.localProxy.username,
|
||||
password: this.localProxy.password,
|
||||
}),
|
||||
fetchAgent: makeProxyAgent({
|
||||
fetchAgent: makeProxyAgentUndici({
|
||||
host: this.localProxy.host,
|
||||
port: this.localProxy.port,
|
||||
protocol: this.localProxy.protocol,
|
||||
|
||||
Reference in New Issue
Block a user