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
drag leaks the source ElementHandle when the target uid lookup fails #2440
The drag tool resolves both element handles before its try/finally:
// src/tools/input.ts, drag handlerconstfromHandle=awaitrequest.page.getElementByUid(request.params.from_uid);consttoHandle=awaitrequest.page.getElementByUid(request.params.to_uid);// can throwtry{
...drag...
}finally{voidfromHandle.dispose();voidtoHandle.dispose();}
If getElementByUid(to_uid) throws — which it does for a stale or invalid to_uid (Element uid "…" no longer exists on the page., Element uid "…" not found, or No snapshot found) — the try block is never entered, so the already-acquired fromHandle is never disposed. getElementByUid mints a fresh ElementHandle per call, so each failed drag leaks one remote object for the life of the page's execution context.
This is the same class of leak as the recently-fixed #2422 (take_screenshot). Among the multi-handle input tools, fill_form (via fillFormElement) already wraps each handle in try/finally, so drag is the only one affected.
Reproduction
Take a snapshot to get element uids.
Call drag with a valid from_uid and a to_uid that no longer resolves (e.g. the DOM changed since the snapshot, or a bad uid).
getElementByUid(to_uid) throws; the call fails and fromHandle is leaked. Repeat → remote objects accumulate until page teardown.
Expectation
The source handle is disposed even when the target lookup fails, matching the other input handlers.
Fix: acquire toHandle inside a nested try so fromHandle is disposed on every path. I have this plus a regression test (spy fromHandle.dispose, force the target lookup to throw, assert dispose was still called) passing locally and can open a PR.
Activity
refactor: introduce Explicit resouce managent (using) (ChromeDevTools…