Skip to content

fix(humanize): share timeout budget in select_option (follow-up to #307) - #354

Open
Kumario1 wants to merge 2 commits into
CloakHQ:mainfrom
Kumario1:fix/select-option-timeout-budget
Open

fix(humanize): share timeout budget in select_option (follow-up to #307)#354
Kumario1 wants to merge 2 commits into
CloakHQ:mainfrom
Kumario1:fix/select-option-timeout-budget

Conversation

@Kumario1

@Kumario1 Kumario1 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #307.

58ccdb6 fixed the multi-wait timeout bug (a 5s timeout waiting ~15s) for
click / dblclick / hover / dragAndDrop on frame and ElementHandle by
sharing a single deadline + remainingMs() budget. The select_option
paths were missed and still have the same class of bug.

Each select_option helper computes a shared deadline for the actionability +
hover steps, but then calls the native select_option with the original
full
timeout instead of the remaining budget — so the native call restarts the
clock. A slow <select> can therefore wait up to ~2× the requested timeout.
The frame-level wrapper didn't even compute a deadline (full timeout to both the
hover and the native select).

Changes

Thread the remaining budget into the native call across every variant:

  • page _human_select_option (sync + async)
  • ElementHandle _human_el_select_option (sync + async) — both the
    move-failed early-return and the normal path
  • frame _frame_select_option (sync + async) — add a shared deadline
  • Locator _humanized_select_option (sync + async) now delegates to
    page.select_option (like click/hover/fill already do), so there's a
    single source of truth for the budget instead of a second hover + native wait

Testing

python -m pytest tests/test_humanize_unit.py -k TestSelectOptionTimeoutBudget
# 3 passed

New TestSelectOptionTimeoutBudget:

  • page native select_option receives the remaining budget (< 5000), not the full timeout
  • Locator.select_option delegates to page.select_option with the forwarded timeout
  • frame select_option shares one deadline across hover + native select

Each test fails against the pre-fix behaviour. Full tests/test_humanize_unit.py
run: 76 passed; the only failures are 5 async tests that also fail on a clean
main here (the env has no pytest-asyncio configured) — unrelated to this change.

Kumario1 added 2 commits June 5, 2026 15:52
CloakHQ#307 fixed the multi-wait timeout bug for click/dblclick/hover/
dragAndDrop on frame and ElementHandle, but the select_option paths
were missed: each computes a shared deadline for actionability + hover,
then calls the native select_option with the ORIGINAL full timeout
instead of the remaining budget. A slow <select> could therefore wait
up to ~2x the requested timeout.

Thread the remaining budget into the native call across all variants:

- page-level _human_select_option (sync + async)
- ElementHandle _human_el_select_option (sync + async), both the
  move-failed early return and the normal path
- frame _frame_select_option (sync + async) — add a shared deadline
- Locator _humanized_select_option (sync + async) now delegates to the
  page-level method (like click/hover/fill) so there is a single
  source of truth for the budget instead of a second hover+native wait

Refs CloakHQ#307.
Adds TestSelectOptionTimeoutBudget: the page-level native select_option
receives the remaining budget (< requested) rather than the full
timeout, the Locator wrapper delegates to page.select_option with the
forwarded timeout, and the frame wrapper shares one deadline across
hover + native select. Each would fail against the pre-fix behaviour
(full timeout / no delegation). Refs CloakHQ#307.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant