ChildProcess: support bidirectional (duplex) additional file descriptors
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #8905 by @effect-bot — merged
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- backend
Research direction
Start from the ChildProcessOptions.additionalFds type and NodeChildProcessSpawner implementation in the platform-node-shared package. Add a duplex variant to AdditionalFdConfig that provides both a Stream and a Sink for the same descriptor, then extend ChildProcessHandle with a getDuplexFd method. Verify the change with the existing child process test suite.
Written by the indexing model from the issue text.
Description
What is the problem this feature would solve?
ChildProcessOptions.additionalFds only lets you configure each extra descriptor in one direction:
type AdditionalFdConfig =
| { readonly type: "input"; readonly stream?: Stream<Uint8Array, PlatformError> }
| { readonly type: "output"; readonly sink?: Sink<Uint8Array, Uint8Array, never, PlatformError> }
The Node spawner (@effect/platform-node-shared/NodeChildProcessSpawner) sets each configured fd to "pipe". For fd ≥ 3, Node backs that with a bidirectional Unix domain socket. Effect then exposes it either as a Sink (getInputFd) or as a Stream (getOutputFd), never both. And because additionalFds is keyed by fd name, one descriptor can't be declared as both input and output.
So there's no way to run a request/response protocol between parent and child over a single inherited socket, e.g. a sidecar speaking a framed protocol on fd 3. Code that needs this has to call node:child_process spawn with stdio: [..., "pipe"] directly and drive child.stdio[3] itself. That means giving up ChildProcessSpawner and doing manual lifecycle, exit and error handling plus raw event listeners. The workaround of using two descriptors (fd 3 in, fd 4 out) changes the child's protocol contract and isn't always an option.
What is the feature you are proposing to solve the problem?
Add a duplex variant to AdditionalFdConfig, for example:
additionalFds: { fd3: { type: "duplex" } }
ChildProcessHandle would then expose both directions for that fd, e.g. a getDuplexFd(fd) that returns { stream, sink }. Alternatively, getInputFd and getOutputFd could both work on the same "duplex" descriptor.
What alternatives have you considered?
- Using
node:child_processspawndirectly and drivingchild.stdio[3]manually, which is what we do today. - Splitting the protocol across two unidirectional descriptors. This needs a change on the child side and doesn't match socket semantics such as half-close and shutdown.
Version: [email protected], @effect/[email protected].
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 808
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 453
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 1/5 1-3 hours Newbie friendliness 86/100
Effect-TS/effect#8863 · 1 comment ·
Maintainers usually reply within 1 day
-
BrowserWorkerRunner: port finalizer throws when the worker global has no close() (Bun)Possibly taken @santiago-ramos-02 claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Effect-TS/effect#8635 · 3 comments ·
Maintainers usually reply within 1 day
-
Support {self: this} for fnUntracedMay be free again @ArjunCodess claimed this 19 days ago, and no pull request is open. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Effect-TS/effect#8101 · 1 comment ·
Maintainers usually reply within 1 day
-
Support delayed jobs in PersistedQueuePossibly taken @tim-smart claimed this today. Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 48/100
Maintainers usually reply within 1 day
All issues in Effect-TS/effect
Similar issues
-
area: backend bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
snapotter-hq/SnapOtter#2254 ·
Maintainers usually reply within 1 day
-
bug ticket
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cratestack/cratestack#1154 ·
Maintainers usually reply within 1 day
-
server 消息处理器 cmd 分支补显式错误回报——竞态非法命令现走未处理拒绝Possibly taken @openaddr claimed this today. Openready-for-agent refactor wayfinder:task
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openaddr/dafung-web#428 ·
Maintainers usually reply within 1 day
-
Flaky: mongodb-memory-server 'Port already in use' when another process starts a mongod concurrentlyOpenarea:testing bug effort:S priority:P2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
lens:agent lens:process process
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
thebristolsound/birdbrain#1772 ·
Maintainers usually reply within 1 day