Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: context_browse.route is broken for requests initiated by service worker #2346

Closed
LironHaroni opened this issue Mar 7, 2024 · 1 comment
Assignees
Labels

Comments

@LironHaroni
Copy link
Contributor

LironHaroni commented Mar 7, 2024

Version

v1.42.0

Steps to reproduce

browser.route("https://example.com/g.json", lamda route: route.fulfill(json={"1": "6"}))
in serviceworker.js:
const response = fetch("https://example.com/g.json").then(res => res.json())

Expected behavior

response in service worker should be { "1": "6" }

Actual behavior

ERROR    asyncio:base_events.py:1707 Task exception was never retrieved
future: <Task finished name='Task-43' coro=<BrowserContext._on_route() done, defined at /home/pwuser/.local/lib/python3.8/site-packages/playwright/_impl/_browser_context.py:221> exception=KeyError('frame')>
Traceback (most recent call last):
  File "/home/pwuser/.local/lib/python3.8/site-packages/playwright/_impl/_browser_context.py", line 223, in _on_route
    page = route.request._safe_page()
  File "/home/pwuser/.local/lib/python3.8/site-packages/playwright/_impl/_network.py", line 271, in _safe_page
    return cast("Frame", from_channel(self._initializer["frame"]))._page
KeyError: 'frame'

Additional context

Created a fix for this issue: #2345

Environment

- Operating System: Ubuntu 22.04
- Browser: All
- Python Version: 3.12
- Other info:
@mxschmitt
Copy link
Member

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants