@@ -13,7 +13,7 @@ import {
1313} from '@powersync/common' ;
1414import { BSON } from 'bson' ;
1515import Agent from 'proxy-agent' ;
16- import { ProxyAgent } from 'undici' ;
16+ import { ProxyAgent , EnvHttpProxyAgent } from 'undici' ;
1717import { WebSocket } from 'ws' ;
1818
1919export const STREAMING_POST_TIMEOUT_MS = 30_000 ;
@@ -32,10 +32,8 @@ export class NodeRemote extends AbstractRemote {
3232 protected logger : ILogger = DEFAULT_REMOTE_LOGGER ,
3333 options ?: Partial < AbstractRemoteOptions >
3434 ) {
35- // Automatic env vars are not supported by undici
36- // proxy-agent does not work directly with dispatcher
37- const proxy = process . env . HTTPS_PROXY ?? process . env . HTTP_PROXY ;
38- const agent = proxy ? new ProxyAgent ( proxy ) : undefined ;
35+ // Automatically uses relevant env vars for HTTP
36+ const agent = new EnvHttpProxyAgent ( ) ;
3937
4038 super ( connector , logger , {
4139 ...( options ?? { } ) ,
@@ -50,8 +48,7 @@ export class NodeRemote extends AbstractRemote {
5048
5149 protected createSocket ( url : string ) : globalThis . WebSocket {
5250 return new WebSocket ( url , {
53- // Undici does not seem to be compatible with ws, using `proxy-agent` instead.
54- // Automatically uses WS_PROXY or WSS_PROXY env vars
51+ // Automatically uses relevant env vars for web sockets
5552 agent : new Agent . ProxyAgent ( ) ,
5653 headers : {
5754 'User-Agent' : this . getUserAgent ( )
0 commit comments