diff options
| author | amankumarsingh77 <amankumarsingh7702@gmail.com> | 2026-07-28 19:57:27 +0530 |
|---|---|---|
| committer | Aman Kumar <145339995+amankumarsingh77@users.noreply.github.com> | 2026-08-02 19:12:46 +0530 |
| commit | 8ccff6c98b04666401b041002ca4aab997e1ff22 (patch) | |
| tree | 395ddd4106bd3ce075de50e6413a40ce8a450168 /src | |
| parent | cfa1892e17e3696da004c71a4942d5b12186b12c (diff) | |
fix(domains): report a page-side throw instead of blaming the ref
runOnElement checked only whether Runtime.callFunctionOn reached Chrome, not
whether the function it ran threw. A page-side exception left result.value
undefined, the result guard rejected it, and browser_fill, browser_focus and
browser_select_option all reported "No element matched: <ref>" for an element
that was there — sending the agent to re-snapshot a ref that was fine and
discarding the real error. The throw is now surfaced as cdp_error carrying the
exception text, which is distinguishable from both the no-match and stale-ref
paths; those still fire for a genuinely missing or stale element. The selector
path already reported throws correctly via evaluateJs.
Report: docs/superpowers/reports/2026-07-26-bug-audit.md#f2
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/domains/form.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/domains/form.ts b/src/domains/form.ts index d8cbf87..78e3db1 100644 --- a/src/domains/form.ts +++ b/src/domains/form.ts @@ -48,6 +48,13 @@ const runOnElement = async ( returnByValue: true, }); if (!r.success) return r; + if (r.data.exceptionDetails !== undefined) { + return err({ + kind: "cdp_error", + message: `page function threw: ${r.data.exceptionDetails.text}`, + details: { ref: opts.ref }, + }); + } return ok(r.data.result.value); } if (opts.selector === undefined) { |
