Skip to content

Browser path crashes on Python 3.14 (Playwright Sync API inside the asyncio loop) #9

Description

@enieuwy

Summary

On Python 3.14, every code path that launches the browser (institutional access via fetch/batch, federated-login, login) fails immediately with:

[ERROR] instsci.auth: Failed to start CloakBrowser: It looks like you are using
Playwright Sync API inside the asyncio loop. Please use the Async API instead.

This makes all institutional/CloakBrowser fetching non-functional on 3.14, regardless of credentials or configuration. OA/arXiv HTTP fetches are unaffected.

Repro

  1. python3.14 -m venv .venv && .venv/bin/pip install -e .
  2. Configure any institutional path, then instsci fetch <closed-access DOI> (or instsci federated-login -p tandfonline).
  3. Resolution reaches "Opening browser for login…" and then raises the error above.

Root cause

Python 3.14 changed event-loop/asyncio internals such that Playwright's Sync API now detects a running loop where it previously didn't, and refuses to run. CloakBrowser/instsci drive Playwright via the sync API from within an async context, which 3.14 rejects. Playwright does not yet officially support 3.14.

Confirmation

Recreating the venv on Python 3.12.13 resolves it — session-doctor and the browser launch path run with no sync/async error. So this is environmental (Python 3.14), not a logic bug.

Suggested mitigation

Pick one (or more):

  • Version guard: have setup/doctor warn (or refuse the browser path) when running on Python ≥ 3.14, with a clear "use 3.12/3.13" message — fits the existing precondition-envelope style.
  • Pin supported range in pyproject.toml (requires-python = ">=3.10,<3.14") until Playwright supports 3.14.
  • Longer term: migrate the browser driver to Playwright's async API so it's robust to loop changes.

Happy to send a PR for the doctor/requires-python guard if that direction is acceptable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions