-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
playwright expect_response() now throws error when trying to parse method #186
Comments
Hello, what Python version and OS are you using? |
Hi @daijro, I've experienced this issue as well
My Dockerfile
|
@princ3od Thanks. Would you (or anyone else reading) be able to provide a small script that I could run and reproduce the issue? I'm looking into why I don't seem to be running into this issue on my environment ( I can be reached privately at daijro.dev@gmail.com 👍 |
Perhaps your environment still use the FF134 from the cache. As my old image still work normally, only the newly built-from-scratch images have this issue. I use docker compose docker compose up → work
docker compose up --built → raise `: Protocol error (Network.getResponseBody): is.setData is not a function` when try using `.json()` |
I can't share the related work, but I'm encountering this issue in an environment with Python 3.11 and playwright==1.48.0. |
Same with Python 3.13.2 and Playwright 1.50 (both Javascript and Python clients are affected, both on Debian and MacOS). Rolling back to FF134 like mentioned here solves the issue. |
A little bit overkill for a script but here a full docker set up to reproduce the issue requirements.txtcamoufox[geoip]==0.4.10
fastapi==0.115.6
uvicorn[standard]==0.34.0 DockerfileFROM python:3.10-slim
WORKDIR /app
# Install Python and other tools
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
xvfb \
flac \
&& apt-get clean
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONBUFFERED 1
ENV PORT 8080
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Install Playwright dependencies & Camoufox
RUN playwright install-deps && \
python3 -m camoufox fetch
COPY . .
CMD exec uvicorn main:app --host 0.0.0.0 --port 8081 docker-compose.ymlversion: '3'
services:
service:
build: .
environment:
PORT: 8081
ports:
- "8081:8081"
volumes:
- .:/app main.pyfrom fastapi import FastAPI
from camoufox.async_api import AsyncCamoufox
app = FastAPI()
@app.get("/")
async def run():
try:
async with AsyncCamoufox(
headless="virtual",
geoip=True,
block_images=True,
) as browser:
page = await browser.new_page()
await page.goto("https://www.youtube.com/", wait_until="commit")
async with page.expect_response(
lambda response: "guide" in response.url
) as response_value:
response = await response_value.value
json_response = await response.json()
print(json_response)
except Exception as e:
print(f"Error: {e}", flush=True)
return {"status": "error"}
return {"status": "success"} Rundocker compose up --build Then, open Error
|
Fix for a regression caused by this change in FF135: https://hg.mozilla.org/mozilla-central/rev/adc7412eeab1a4fcb8f10211a268b799c22350a3
@princ3od Thanks for the code snippet! Seems like the issue was only present on sites with certain response encoding types, which made it difficult to test/find. I have just pushed a fix. |
v135.0-beta.22 is out now — it should fix the issue 👍 |
Awesome work man! Confirmed the issue is fixed on my newly built images 💪🏻 |
Thank you @daijro ! |
Describe the bug:
Even though the response itself has a
200
status, playwright is no longer to read the output of thejson()
,text()
, orbody()
methods with the latest update. it throws the errorwill linclude larger error below
Screenshots:
If applicable, add screenshots to help explain your problem.
To Reproduce:
Version:
longer error
The text was updated successfully, but these errors were encountered: