#Bypass `undici` replacement (for SOCKS support)

1 messages · Page 1 of 1 (latest)

rare tartan
#

One thing stops me from migrating to Bun: lack of SOCKS4/5 support (specifically - ProxyAgent).
I see that is not implemented in local undici analog.
Is there any legit workaround to use original undici?
I've tried this one in package.json:

"dependencies": {
    "@undicijs/undici": "npm:[email protected]"
}

And use import * as undici from "@undicijs/undici"; instead of import * as undici from "undici"; - it works in my own code but breaks in existing packages that work with undici directly - needs patching.
Is there any way without patching packages?
Maybe env flag or something?

rare tartan
#

Bypass undici replacement (for SOCKS support)

sterile canopy
#

Or at least smarter to just improve a few things and not break all else

rare tartan
#

Btw, I can't patch a package with Bun when this dep hack is used:

$ bun patch @undicijs/proxy
[0.00ms] ".env"
bun patch v1.2.2 (c1708ea6)

Checked 70 installs across 100 packages (no changes) [168.00ms]

To patch @jsr/undicijs__proxy, edit the following folder:

  node_modules/@undicijs/proxy

Once you're done with your changes, run:

  bun patch --commit 'node_modules/@undicijs/proxy'

<here is patching process...>

$ bun patch --commit 'node_modules/@undicijs/proxy'
[0.00ms] ".env"
bun patch v1.2.2 (c1708ea6)
error: failed applying patch file: ENOENT: node_modules/undici/LICENSE: No such file or directory (open())

Checked 69 installs across 100 packages (no changes) [966.00ms]
error: failed to apply patchfile (patches/@jsr%[email protected])

My package.json contains these rows:

  "dependencies": {
    "@undicijs/proxy": "npm:@jsr/[email protected]",
    "@undicijs/undici": "npm:[email protected]",
    ...
  }

Patch file contains all the diff between node_modules/@undicijs/proxy and node_modules/undici folders (first one is the renamed module, second one is original, not existing). pnpm patch works fine.

sterile canopy
#

i think you should be able to make the patch file manually, but yeah this issue i also have sadly hard of :(