Typed unix socket and TLS options for `BunHttpClient` and `DenoHttpClient`
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- TypeScript
- 星标
- 16.7k
- 派生
- 808
- 平均合并
- 10 小时 7 分钟
- 30 天内合并 PR
- 808
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Effect-TS/effect 的其他 Issue
-
Support {self: this} for fnUntraced可能已有人在做 @ArjunCodess 于 32 天前认领。 未关闭enhancement
难度 2/5 1-3 小时 新手友好度 70/100
Effect-TS/effect#8101 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
维护者通常 1 天内回复
-
v4 Cache.get: a caller that joins an abandoned lookup fails with an interruption it did not ask for未关闭
难度 4/5 3-5 天 新手友好度 42/100
维护者通常 1 天内回复
-
RFC 9457 Problem Details for HttpApi errors可能已有人在做 @effect-bot 今天认领。 未关闭docker-made-me-do-it enhancement
难度 5/5 一周以上 新手友好度 20/100
维护者通常 1 天内回复
-
Typed parsers and formatters for common HTTP header values可能已有人在做 @effect-bot 今天认领。 未关闭docker-made-me-do-it enhancement
Effect-TS/effect#9685 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
paperclipai/paperclip#17151 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 83/100
AgoraIO-Extensions/agent-infra#3159 ·
维护者通常 1 天内回复
-
blocklist addition
难度 1/5 1 小时以内 新手友好度 66/100
MetaMask/eth-phishing-detect#304596 ·
维护者通常 1 天内回复
-
friction
难度 2/5 1-3 小时 新手友好度 70/100
kentcdodds/kody#4142 ·
-
[Bug] Statistics | Task statistics are always empty on MikroORM with MySQL or SQLite可能已有人在做 @NdekoCode 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
ever-co/ever-gauzy#11214 ·
维护者通常 1 天内回复