e2b-dev / e2b-dev/runtime

envd: distinguish expected stdin lifecycle errors from CodeInternal

Open
#3,622 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.6k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Problem

Process.SendInput currently maps every Handler.WriteStdin failure to
CodeInternal.

Some of these failures are expected process lifecycle outcomes:

  • stdin is disabled or already closed;
  • a PTY process receives stdin input;
  • the process exits and its stdin pipe returns EPIPE/file-already-closed.

CodeInternal is reserved for serious invariant failures, so clients cannot
distinguish a normal process-state transition from an unexpected envd failure.

This also races with the Start response stream: SendInput can return
CodeInternal before the process's EndEvent arrives on the independent stream.

Proposed semantics

  • process selector no longer exists: CodeNotFound
  • process exists but cannot accept stdin: CodeFailedPrecondition
  • unexpected underlying I/O failure: CodeInternal

CloseStdin should follow the same error taxonomy.

The EndEvent remains authoritative for exit status; a SendInput error alone
must not be treated as the terminal process result.

Compatibility

This changes observable Connect error codes, although callers that only check
for a non-nil error are unaffected. Python and JavaScript SDK behavior should
be checked before merging.

Reproduction

Start a short-lived non-PTY process, wait for its stdin pipe to close, then
call SendInput before the delayed EndEvent is delivered. The current service
returns CodeInternal for the closed pipe.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Process.SendInput, Handler.WriteStdin, and CloseStdin, then trace how Connect exposes their errors and how the independent EndEvent stream reports termination. Check the Python and JavaScript SDK handling of these errors. Done means nonexistent selectors produce CodeNotFound, unavailable stdin produces CodeFailedPrecondition, unexpected I/O remains CodeInternal, and EndEvent remains authoritative.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, javascript, python
Domain
api, backend, backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.