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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dhu3iHseRewQ2WpBSVLokG
This commit is contained in:
1 parent
baf43525f6
commit
cd6e02be11
1 file changed
+5
-1
@@ -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])
|
||||
|
||||
Reference in new issue
Block a user