Typed unix socket and TLS options for `BunHttpClient` and `DenoHttpClient`
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Problem
NodeHttpClient has typed layers for connecting over a unix socket and for custom TLS (#9158):
NodeHttpClient.layerUndiciOptions({ connect: { socketPath: "/var/run/docker.sock" } })
NodeHttpClient.layerUndiciOptions({ connect: { ca, cert, key, servername } })
Bun and Deno have nothing equivalent: BunHttpClient and DenoHttpClient only re-export FetchHttpClient. Both runtimes can do the same things, but only through fetch fields that aren't in the standard RequestInit:
- Bun:
fetch(url, { unix, tls: { ca, cert, key, rejectUnauthorized, serverName } }) - Deno:
fetch(url, { client }), where the client comes fromDeno.createHttpClient({ caCerts, cert, key, proxy: { transport: "unix", path } })and has to be closed afterwards.
You can get there by providing FetchHttpClient.RequestInit or a custom Fetch, but it isn't documented, and the types don't fit. Effect's own Kubernetes integration, which only needs to trust one CA file, does it three different ways:
- Node: an undici
Agent(packages/platform/node/src/NodeClusterSocket.ts:150-174). - Bun:
{ tls: { ca } } as any(packages/platform/bun/src/BunClusterSocket.ts:156-160). - Deno: a wrapped
fetchthat injectsclientwithas anyand closes it when the scope ends (packages/platform/deno/src/DenoClusterSocket.ts:197-201).
Anyone who needs the Docker socket on Bun, or a client certificate on Deno, has to rediscover all of this.
Proposal
One layer per runtime that takes that runtime's own options, the same way the Node layers take undici's options:
BunHttpClient.layerOptions({ unix: "/var/run/docker.sock" })
BunHttpClient.layerOptions({ tls: { ca, cert, key } })
DenoHttpClient.layerOptions({ proxy: { transport: "unix", path: "/var/run/docker.sock" } })
DenoHttpClient.layerOptions({ caCerts: [ca], cert, key })
- Bun passes the options into every fetch call.
- Deno creates the
Deno.HttpClientin the layer's scope and closes it when the scope ends. - The JSDoc for each layer says what is supported. For example, Deno has no option to skip certificate verification or to set the server name.
Then switch the Bun and Deno Kubernetes layers over and remove the casts.
Why in Effect
HttpClient is meant to be portable, yet on two of the three server runtimes these settings are only reachable through untyped, undocumented fields. This is the Node change from #9158 applied to Bun and Deno, with no new concepts.
Scope
In scope:
layerOptionsfor Bun and Deno, with docs.- Using them in the Kubernetes layers.
Out of scope:
- A connection or TLS type shared by all runtimes.
http+unix://URLs, which have no standard scheme.- Per-request connection settings.
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 808
- Avg merge
- 10h 52m
- Merged PRs (30d)
- 836
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Effect-TS/effect
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
RpcServer: with disableFatalDefects, a handler that throws before returning its Effect still fails every pending callPossibly taken @effect-bot claimed this today. Open
Effect-TS/effect#9892 · 1 assignee ·
Maintainers usually reply within 1 day
-
Duration: ISO 8601 format/parse and a Schema codec (exact units only)Possibly taken @jayhemnani9910 claimed this today. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Effect-TS/effect#9888 · 1 comment ·
Maintainers usually reply within 1 day
-
HttpApiClient: `Redacted` query and header values appear in plain text in client spansPossibly taken @effect-bot claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Effect.fn stack frames keep the call's arguments alive in forked fibersPossibly taken @Hona claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
Maintainers usually reply within 1 day
All issues in Effect-TS/effect
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
farion1231/cc-switch#8829 ·
Maintainers usually reply within 1 day
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverOpendoc-audit enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
neondatabase/neon-pkgs#941 ·
Maintainers usually reply within 1 day