fix(sandbox): name a failed Function's error from its headline, not an inspected property

Merged
WA
16d ago
+212-4

Summary

  • A failed sandboxed Function (E2B / Daytona, JavaScript and Python) named its error from the last trimmed identifier: value line of stderr. Node prints an error's own properties indented beneath it, so the error took the name of a property: a fetch that lost its socket surfaced as bytesRead: 0 (a reset as syscall: 'read'), an ENOENT as its path, a custom error as one of its fields, a missing module as code: 'ERR_MODULE_NOT_FOUND'.
  • Match only top-level error headlines: unindented, with a space after the colon (so source-location headers like node:internal/x:12 / file:///x.mjs:3 don't match), plus Node's Name [CODE]: message and bracketed [Name: message] { forms. The traceback itself is unchanged and still returned in full.

Type of Change

  • Bug fix

Testing

  • Ran 33 real failure shapes through node 22 and python3 (socket closed / reset / refused fetches, custom errors with properties, ENOENT, coded Node errors, AggregateError, cause chains, thrown strings/objects, syntax errors, Python tracebacks incl. chained, custom-module and SyntaxError) and compared old vs new parser: 13 now name the real error, 20 unchanged (every Python case), none worse
  • New code-failure.test.ts built from real stderr fixtures; 5 of its cases fail on the previous parser (incl. the bytesRead: 0 fetch case), Python cases pass on both
  • biome on changed files

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)