Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun's hijacking of the "ws" module removes agent support #18050

Open
VillainsRule opened this issue Mar 11, 2025 · 0 comments
Open

Bun's hijacking of the "ws" module removes agent support #18050

VillainsRule opened this issue Mar 11, 2025 · 0 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs `ws` package

Comments

@VillainsRule
Copy link

What version of Bun is running?

1.2.4+fd9a5ea66

What platform is your computer?

Darwin 24.4.0 arm64 arm

What steps can reproduce the bug?

  1. Find a socks5(h) proxy
  2. Install the "socks-proxy-agent" dependency (and the "ws" for testing on Node.JS)
  3. Run this minimal example on Bun and Node
import { SocksProxyAgent } from 'socks-proxy-agent';
import { WebSocket } from 'ws';

const proxy = 'socks5h://...';

let ws = new WebSocket('wss://echo.schooling.workers.dev/', {
    agent: new SocksProxyAgent(proxy)
});

ws.onmessage = (m) => console.log(m.data);

The console will, on Bun, log your IP. On Node, the console will log the proxy's IP.

What is the expected behavior?

I expect that Bun will use the agent and output the correct IP address.

What do you see instead?

Instead, I see my computer's IP address.

Additional information

This is similar to Bun failing to support agents on http requests. However, this is very annoying (and overall different) considering that:

  1. Bun hijacks the ws module, which would usually make this possible, removing core functionality
  2. Attempting to directly load the ws via node_modules throws an error due to a lack of support.

It would be incredibly nice if we could specify something as simple as $ws to get the native module back, or if Bun could implement it.

@VillainsRule VillainsRule added bug Something isn't working needs triage labels Mar 11, 2025
@RiskyMH RiskyMH added `ws` package node.js Compatibility with Node.js APIs and removed needs triage labels Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs `ws` package
Projects
None yet
Development

No branches or pull requests

2 participants