Repository navigation
feat!: bound connection time and harden the transport - #9
Conversation
Bound page connection setup with an independent deadline, apply server timeout headroom once, and harden operation completion and connection cleanup. Keep credentials out of connection error context and traceback locals, propagate synchronous timeouts, and check both distribution formats. BREAKING CHANGE: Opening a page now times out after connect_timeout, which defaults to timeout. Set connect_timeout=0 to restore an unbounded connection wait.
Bound failed-setup cleanup to five seconds, reject connection attempts whose deadline cancellation was suppressed, and drop unformattable log records before handlers can expose credentials.
|
All three review findings are fixed with regression coverage: malformed log records are dropped, expired connection attempts cannot succeed after suppressed cancellation, and failed-setup cleanup has a five-second budget. Current head passes 240 offline tests (one existing optional parity skip), all five live BrowserQL tests against a local runtime, formatting, lint, typing, generation checks, and hosted CI. The missing-selector case returns the server error mentioning 1500ms. No unresolved review threads or merge conflicts remain. Ready for human review; no merge or release performed. |
|
All three initial review findings are fixed: malformed log records are dropped before handler diagnostics, expired connection deadlines remain errors after suppressed cancellation, and failed-setup cleanup is bounded. Regression coverage passes: 240 offline tests and five live BrowserQL tests. All 14 current-head checks pass; no unresolved review threads or merge conflicts remain. The PR is ready for human review. No remaining review findings were rejected. |
Review: ready to mergeEvery planned item is present. 38 of the 79 new non-sync tests fail on main's code and the new sync test hangs there, so the tests catch the old bugs. All three CodeRabbit findings are fixed, each with a regression test. Lint, mypy and the offline suite pass on 3.11, 3.12 and 3.14 (240 passed, 1 skipped). Codegen and the schema check leave no diff, and Live probes on dev
Minor (none blocking)
Merge order: whichever of #8 and #9 lands second needs a rebase, because #8 renames the exceptions to |
Observe shared connection-task failures even when every waiter cancels, without changing what remaining awaiters receive. Scope logging redaction documentation to the filtered WebSocket logger. Co-authored-by: Artiom Lunev <artiom@browserless.io>
|
Items 1 and 5 are fixed in d1a3a7d: shared connection-task failures are retrieved even after all waiters cancel, and README/llms redaction claims now name the filtered WebSocket logger. The new cancellation regression reproduced the asyncio warning before the fix; the updated offline suite passes 241 tests (one existing optional skip), along with Ruff, mypy, generation, schema and package checks. Item 2 retains the deliberate fail-closed record drop to avoid handler diagnostics leaking malformed input. The later protocol-handling suggestions in items 3 and 4 remain unchanged. Live acceptance passed five tests before this callback-only follow-up and was not rerun afterward. Rebase integration still needs to preserve BAP-prefixed exceptions, opt_in forwarding and the completed-future sync guard. |
|
Follow-up verification is complete at d1a3a7d: all 13 current-head checks pass, including Python 3.11–3.14, and the latest CodeRabbit review reports no actionable comments. No unresolved review threads or merge conflicts remain. The PR remains ready for human review; the prior live-test attribution and non-blocking protocol notes are unchanged. |
Keep both new live tests and count six skipped live tests.
Gikoskos
left a comment
There was a problem hiding this comment.
Approved: review findings handled, and live tests pass on the merged head.
🤖 I have created a release *beep* *boop* --- ## [0.3.0](v0.2.0...v0.3.0) (2026-11-13) ### ⚠ BREAKING CHANGES * `Page.query_selector()` and `Page.query_selector_all()` no longer fetch `innerHTML`/`outerHTML`; pass `html=True`. Reading `ElementHandle.inner_html` or `outer_html` on a handle queried without it raises `BAPValueError`. `Page.response()` no longer returns `body`; pass `body=True` (or `body_encoding=True`, which implies it). the exceptions `TimeoutError`, `ConnectionError` and `ValueError` are removed from `browserless_bap` and `browserless_bap.errors`; use `BAPTimeoutError`, `BAPConnectionError` and `BAPValueError` (they still subclass the matching built-in exceptions). `browserless_bap.graphql.RESPONSE_FIELDS` no longer has the `HTTPResponseWithRemoteMetadata` and `ResponseResponseWithBodyEncoding` keys; use `OPTIONAL_FIELDS` with `selection_for()`. `QuerySelectorResponse["childElementCount"]` is typed `int` (was `float`), and `browserless_bap.sync_api.Browserless.connect(transport=...)` is typed `TransportFactory | None` (was `Any`). * Opening a page now times out after `connect_timeout` (default: the `timeout` value, 30000 ms). Pass `connect_timeout=0` to restore the previous unbounded wait. ### Features * bound connection time and harden the transport ([#9](#9)) ([1689f3b](1689f3b)) * make element HTML and response bodies opt-in and rename builtin-shadowing errors ([#8](#8)) ([bc80671](bc80671)) ### Bug Fixes * encode element handle selectors so nested and special-character queries work ([#6](#6)) ([f22f12b](f22f12b)) * sync API listener delivery, wait_for_function predicates and parity checks ([#7](#7)) ([e5a106d](e5a106d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: browserless-actions-bot[bot] <186328842+browserless-actions-bot[bot]@users.noreply.github.com>
Summary
connect_timeout, shared by async and sync APIs. Clean up failed or cancelled setup without cancelling another operation's shared connection attempt.Related issues
None.
Type of change
Checklist
ruff format --check .ruff check .mypypytest -m "not e2e"— 241 passed, 1 skipped, 5 deselected on Python 3.13pytest -m e2e— 5 passed against a local BrowserQL runtime at c9b91f5, before the final abandoned-task callback fixpython scripts/codegen.pyleaves no diffpython scripts/sync_schema.py --checktwine check, fresh-wheel imports, and archive contents checkedNotes for reviewers
Live BrowserQL acceptance passed: all five tests ran against a local runtime, including async/sync happy paths, rejected authentication, malformed endpoints, and the missing-selector regression receiving the server's
BrowserQLErrormentioning1500ms, rather than the client's timeout. No production endpoint was used.The final follow-up retrieves shared connection-task failures when all waiters cancel and narrows the documented redaction scope to the WebSocket logger. Its cancellation regression failed before the fix and passes afterward; the full offline suite passes. Live tests were not rerun for this callback-only change.
Follow-up regressions also verify that suppressed cancellation cannot accept an expired connection deadline, stalled failed-setup cleanup is limited to five seconds while preserving the original error, and malformed log records are dropped before handler diagnostics can expose credentials.
Offline regressions cover stalled real-socket handshakes and socket closure, synchronous connection and operation deadlines, cancellation isolation, failed setup cleanup, timeout/completion races, stream termination, malformed and empty error payloads, error context and traceback-local redaction, and the operation-timeout truth table. The remaining offline skip is the existing optional source-parity test. A separate focused security scanner is unavailable; the consolidated code review covered security and privacy.
No runtime dependency, schema, package version, or changelog changes. Custom connection factories still receive the same URL string. Operation deadline expiry does not close the page; only connection timeout is terminal for that connection attempt.
Summary by CodeRabbit
BREAKING CHANGE: Opening a page now times out after
connect_timeout(default: thetimeoutvalue, 30000 ms). Passconnect_timeout=0to restore the previous unbounded wait.