You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
evaluate_script doesn't report errors thrown by callbacks it schedules #3430
Is your feature request related to a problem? Please describe.
evaluate_script reports only what its function returns or throws. An error thrown in a callback the function schedules, like a setTimeout, requestAnimationFrame or MutationObserver callback, never reaches the result. The tool answers as if the script ran fine, and the error only shows up in list_console_messages, which an agent has no reason to call after a successful evaluation.
Scripts that measure something over time run into this easily. One of ours collected timings in a MutationObserver callback that threw a ReferenceError on every mutation, so it came back with an empty result and nothing hinted at why.
()=>newPromise(resolve=>{setTimeout(()=>{thrownewError('thrown in a timer');},0);setTimeout(()=>resolve('done'),50);})
This returns "done", and the error is only listed by list_console_messages.
Describe the solution you'd like
List the errors the page throws or logs while the script runs in the evaluate_script response, the way list_console_messages lists them, so their msgid works with get_console_message.
Describe alternatives you've considered
A try/catch in every callback works, but nothing prompts an agent to write one, and it doesn't help when the error comes from the page's own handler for an event the script dispatches.
Additional context
Clicks and key presses have the same gap when a handler they trigger throws, and Playwright MCP links an action's new console entries, page errors included, in its response. I kept the PR to evaluate_script, where it's easiest to run into, but I'm happy to widen it if you'd rather have it for every action.
Does this feature basically boil down to return any console logs that occurred during the evaluate call? Those might not be related to the evaluate call at all. Generally, this is how uncaught exception in JS work so ideally asking the agent to handle all uncaught rejections in their JS code should work. I think it would be useful to detect the console logs during a tool call and surface it to the agent.
Yes, though only errors (what the error filter of list_console_messages covers), and some may well be unrelated, as you say. If you mean doing that for every tool call, that sounds better to me, as a click whose handler throws has the same gap.
Would you keep it to errors? I'd lean that way, since every level after every call gets noisy on chatty pages and the rest is one list_console_messages call away. If that works for you, I'll rework #3431.
Activity
OrKoN commentedon Nov 9, 2026
Does this feature basically boil down to return any console logs that occurred during the evaluate call? Those might not be related to the evaluate call at all. Generally, this is how uncaught exception in JS work so ideally asking the agent to handle all uncaught rejections in their JS code should work. I think it would be useful to detect the console logs during a tool call and surface it to the agent.
thomasbachem commentedon Nov 9, 2026
Yes, though only errors (what the
errorfilter oflist_console_messagescovers), and some may well be unrelated, as you say. If you mean doing that for every tool call, that sounds better to me, as a click whose handler throws has the same gap.Would you keep it to errors? I'd lean that way, since every level after every call gets noisy on chatty pages and the rest is one
list_console_messagescall away. If that works for you, I'll rework #3431.feat: list errors a page raises while a tool runs (ChromeDevTools#3431)