From cd6e02be1139c7c6ba0ce9d7e9b4770688afbb53 Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Wed, 21 Oct 2026 22:27:29 +0000 Subject: [PATCH] harness-cdp: when the harness did not run, print the page's uncaught exceptions (a module that failed to load, say) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01Dhu3iHseRewQ2WpBSVLokG --- tools/harness-cdp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/harness-cdp.py b/tools/harness-cdp.py index 34a8b97..8f2b9c4 100644 --- a/tools/harness-cdp.py +++ b/tools/harness-cdp.py @@ -20,6 +20,7 @@ class WS: assert b" 101 " in buf.split(b"\r\n")[0], buf[:200] self.buf = buf.split(b"\r\n\r\n", 1)[1] self.n = 0 + self.errors = [] # uncaught exceptions the page reported, for the diagnosis def _read(self, n): while len(self.buf) < n: self.buf += self.s.recv(65536) @@ -52,6 +53,9 @@ class WS: self.send({"id": self.n, "method": method, "params": params}) while True: m = self.recv() + if m.get("method") == "Runtime.exceptionThrown": + d = m["params"]["exceptionDetails"]; e = d.get("exception") or {} + self.errors.append(f"{e.get('description') or d.get('text')} @{d.get('url', '')}:{d.get('lineNumber', '')}") if m.get("id") == self.n: return m.get("result", {}) @@ -79,7 +83,7 @@ def main(): r = ws.call("Runtime.evaluate", expression="(document.getElementById('diag')||{}).textContent||''", returnByValue=True) text = r.get("result", {}).get("value", "") or "" if "\nEND" in text or text.startswith("END") or text.startswith("TOPERR"): break - print(text if text else "no diag: the harness did not run") + print(text if text else "no diag: the harness did not run" + "".join("\n " + e.splitlines()[0] for e in ws.errors)) finally: p.kill() subprocess.run(["rm", "-rf", prof])