[Bug]: E2B JSON codec fails every exit-0 command (official envd omits exitCode)
Summary
With E2bCodec.JSON, every command that exits 0 is reported as a failure against
endpoints served by the official E2B envd.
The official envd omits exitCode from a successful end event (the proto3 default is
dropped by protojson), so the frame only carries exited and status:
{"event":{"end":{"exited":true,"status":"exit status 0"}}}
E2bEnvdProcessClient.parseJsonStartResponse attaches the end event only when
exitCodeNode.canConvertToInt() is true (or error is a string). With exitCode
absent, canConvertToInt() is false, the end event is dropped, and
drainStartStream throws envd process stream ended before receiving a process exit code.
Because sandbox bootstrap itself runs commands that exit 0, the E2B backend cannot hand out a sandbox handle against the official envd when the JSON codec is selected.
Evidence — raw Connect-JSON frames from official envd
POST /process.Process/Start on a base sandbox on e2b.app:
| command | end frame |
|---|---|
echo hello |
{"event":{"end":{"exited":true,"status":"exit status 0"}}} |
exit 0 |
{"event":{"end":{"exited":true,"status":"exit status 0"}}} |
false |
{"event":{"end":{"exitCode":1,"exited":true,"status":"exit status 1","error":"exit status 1"}}} |
exit 42 |
{"event":{"end":{"exitCode":42,"exited":true,"status":"exit status 42","error":"exit status 42"}}} |
Exit 0 omits exitCode; non-zero includes it. The success path is exactly the one the
client currently cannot decode.
Not the same as #2609 / #2793
- #2609 fixed the explicit
{"end":{"exitCode":0}}shape (what FC's e2b-compatible envd emits). Its guard isexitCodeNode.canConvertToInt(), which isfalsewhen the field is absent. - The official envd omits the field entirely, so that guard does not cover it.
- #2793 describes the explicit-
0/ FC shape.
Fix
Attach the end event whenever the end key is present; an omitted exit_code is the
proto3 default 0. PR: #3606.