| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…ici 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.
Reviewer's GuideThis PR adds a new Undici-compatible proxy agent generator and updates the WhatsApp Baileys integration to use it for fetchAgent, ensuring compatibility with Node.js 18+ native fetch while preserving legacy proxy support and updating dependencies. Sequence diagram for BaileysStartupService proxy agent selection (Node.js 18+ fetch compatibility)sequenceDiagram
participant BaileysStartupService
participant ProxyConfig
participant makeProxyAgent
participant makeProxyAgentUndici
participant ProxyAgent (undici)
BaileysStartupService->>ProxyConfig: Get proxy configuration
alt Using legacy agent
BaileysStartupService->>makeProxyAgent: Create agent for Axios/legacy
makeProxyAgent-->>BaileysStartupService: Return HttpsProxyAgent/SocksProxyAgent
end
alt Using fetchAgent (Node.js 18+)
BaileysStartupService->>makeProxyAgentUndici: Create agent for fetch
makeProxyAgentUndici->>ProxyAgent (undici): Instantiate ProxyAgent
ProxyAgent (undici)-->>BaileysStartupService: Return ProxyAgent
end
ER diagram for proxy configuration normalizationerDiagram
PROXY {
string host
string protocol
string username
string password
int port
}
PROXY ||--o{ PROXY_URL : normalizes
PROXY_URL {
string url
}
Class diagram for updated proxy agent creation utilitiesclassDiagram
class Proxy {
host: string
password?: string
port?: number
protocol: string
username?: string
}
class HttpsProxyAgent
class SocksProxyAgent
class ProxyAgent
class makeProxyAgent {
+HttpsProxyAgent makeProxyAgent(proxy: Proxy | string)
}
class makeProxyAgentUndici {
+ProxyAgent makeProxyAgentUndici(proxy: Proxy | string)
}
makeProxyAgent --|> HttpsProxyAgent
makeProxyAgent --|> SocksProxyAgent
makeProxyAgentUndici --|> ProxyAgent
Proxy <.. makeProxyAgent
Proxy <.. makeProxyAgentUndici
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commands Interacting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sorry, something went wrong.
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI AgentsPlease address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/utils/makeProxyAgent.ts:58` </location>
<code_context>
+ proxyUrl = proxy
+ } else {
+ const { host, password, port, protocol: proto, username } = proxy
+ protocol = proto.replace(':', '')
+
+ if (protocol === 'socks') {
</code_context>
<issue_to_address>
**issue:** Potential issue if 'proto' is undefined in Proxy object.
Add a check or default value for 'proto' to prevent errors when it is undefined.
</issue_to_address>
Sorry, something went wrong.
|
EDIT: aqui deu certo. mt obrigado |
Sorry, something went wrong.
|
@JefersonRamos isso ja esta na versão 2.3.6? ou vai ser na próxima? |
Sorry, something went wrong.
Já foi dado merge, mas foi direto para main |
Sorry, something went wrong.
…x/media-upload-failed-on-all-hosts
…x/media-upload-failed-on-all-hosts
…x/media-upload-failed-on-all-hosts
| Back | FazBrowse Home | New Git URL |
📋 Description
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.
🔗 Related Issue
Closes #2117
🧪 Type of Change
🧪 Testing
📸 Screenshots (if applicable)
✅ Checklist
📝 Additional Notes
O protocolo socks é automaticamente normalizado para socks5, evitando erro de usuários que informem apenas "socks"
Summary by Sourcery
Introduce Undici-compatible proxy handling by adding makeProxyAgentUndici, updating BaileysStartupService to use it for fetchAgent, and adding undici to dependencies to ensure compatibility with Node.js 18+ native fetch
New Features:
Bug Fixes:
Enhancements:
Build: