Skip to content

The agent that grows with you

test(e2e): keep the whole faulthandler dump when the tui gateway dies on a signal

teknium1f01580ec5c62
diff --git a/tests/e2e/core/chaos/_tui_rpc.py b/tests/e2e/core/chaos/_tui_rpc.py
index 5ed78c08513..2e168a44efa 100644
--- a/tests/e2e/core/chaos/_tui_rpc.py
+++ b/tests/e2e/core/chaos/_tui_rpc.py
@@ -157,9 +157,15 @@ class TuiGatewayProcess:
try:
if not self._stderr_fh.closed:
self._stderr_fh.flush()
- data = self.stderr_path.read_bytes()[-n:].decode(errors="replace")
+ raw = self.stderr_path.read_bytes()
except OSError:
- data = ""
+ raw = b""
+ # A fatal signal's faulthandler dump prints the faulting ("Current thread") stack
+ # FIRST, so a plain byte tail cuts exactly the frame that names the crash: keep the
+ # whole dump from its header when the gateway died on a signal.
+ rc = self.proc.poll()
+ start = raw.rfind(b"Fatal Python error") if rc is not None and rc < 0 else -1
+ data = (raw[start:start + 256_000] if start >= 0 else raw[-n:]).decode(errors="replace")
return f"\n--- gateway stderr tail ---\n{data}" if data else ""