websocket error during Apify run that is not from our code
In the middle of a Python Playwright run, we are getting this error:
We do not have any websocket code in our Actor. The traceback does not have any reference to our code.
7 Replies
generous-apricotOP•15mo ago
Our Actor code is
The worker() task is our crawler that opens a page in playwright and parses a small piece out. We're not sure where, if anywhere, a websocket is running. Since the code is coming from
apify/event_manager.py
we think it's some Apify global code that's running, but we can't find it.rare-sapphire•15mo ago
Our team will reply you soon! cc @Vlada Dusek
vicious-gold•15mo ago
Hi, could you please provide a full reproducible code sample? (what is
async_playwright
and worker
?) Is it happening both locally and on the platform?absent-sapphire•15mo ago
I'll make my assumptions.
async_playwright is a basic input point to asynchronous playwright, you can check it by documentation - https://playwright.dev/python/docs/api/class-playwright.
Judging by the worker code, this is a coroutine that works with the received context and executes a script for web scraping.
I am somewhat confused by this code section.
Is it true that there is always only one task in your tasks? Or did you change the code when copying it here?
Also, I don't see the browser closing anywhere.
Since the error may occur if the browser was not closed correctly.
generous-apricotOP•15mo ago
There is just one task per Actor. We ported this from another Actor we maintain that does multiple. But since this boots a browser, we keep it to one task.
@grackle just advanced to level 3! Thanks for your contributions! 🎉
generous-apricotOP•15mo ago
from playwright.async_api import async_playwright
is that.
The worker code is simply:
I did a big run last night and the websocket error has not returned as far as I can see. I'm wondering if it was something spurious. Do you have any context you can give on where _process_platform_messages
is supposed to run and why it would time out ?