Repository navigation
Closed
Description
After updating, the library always crashing on page.goto method with this error:
File ~/.venv/lib/python3.12/site-packages/scrapling/engines/pw.py:222, in PlaywrightEngine.fetch(self, url)
219 page.add_init_script(path=js_bypass_path('screen_props.js'))
220 page.add_init_script(path=js_bypass_path('playwright_fingerprint.js'))
--> 222 res = page.goto(url, referer=generate_convincing_referer(url) if self.google_search else None)
223 page.wait_for_load_state(state="domcontentloaded")
224 if self.network_idle:
File ~/.venv/lib/python3.12/site-packages/rebrowser_playwright/sync_api/_generated.py:9006, in Page.goto(self, url, timeout, wait_until, referer)
8945 def goto(
8946 self,
8947 url: str,
(...)
8953 referer: typing.Optional[str] = None,
8954 ) -> typing.Optional["Response"]:
8955 """Page.goto
8956
8957 Returns the main resource response. In case of multiple redirects, the navigation will resolve with the first
(...)
9002 Union[Response, None]
9003 """
9005 return mapping.from_impl_nullable(
-> 9006 self._sync(
9007 self._impl_obj.goto(
9008 url=url, timeout=timeout, waitUntil=wait_until, referer=referer
9009 )
9010 )
9011 )
[... skipping hidden 1 frame]
File ~/.venv/lib/python3.12/site-packages/rebrowser_playwright/_impl/_page.py:551, in Page.goto(self, url, timeout, waitUntil, referer)
544 async def goto(
545 self,
546 url: str,
(...)
549 referer: str = None,
550 ) -> Optional[Response]:
--> 551 return await self._main_frame.goto(**locals_to_params(locals()))
File ~/.venv/lib/python3.12/site-packages/rebrowser_playwright/_impl/_frame.py:145, in Frame.goto(self, url, timeout, waitUntil, referer)
135 async def goto(
136 self,
137 url: str,
(...)
140 referer: str = None,
141 ) -> Optional[Response]:
142 return cast(
143 Optional[Response],
144 from_nullable_channel(
--> 145 await self._channel.send("goto", locals_to_params(locals()))
146 ),
147 )
File ~/.venv/lib/python3.12/site-packages/rebrowser_playwright/_impl/_connection.py:61, in Channel.send(self, method, params)
60 async def send(self, method: str, params: Dict = None) -> Any:
---> 61 return await self._connection.wrap_api_call(
62 lambda: self._inner_send(method, params, False),
63 self._is_internal_type,
64 )
File ~/.venv/lib/python3.12/site-packages/rebrowser_playwright/_impl/_connection.py:528, in Connection.wrap_api_call(self, cb, is_internal)
526 return await cb()
527 except Exception as error:
--> 528 raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
529 finally:
530 self._api_zone.set(None)
Exception: Page.goto: Connection closed while reading from the driver
I'm using MacOS and the latest Playwright browsers, have you read the changes to Chrome headless in Playwright 1.49? I think it's related.
Metadata
Metadata
Assignees
Labels
No labels
Activity
nwebson commentedon Dec 7, 2024
Could you share your code causing the error?
D4Vinci commentedon Dec 7, 2024
@nwebson Here's a representation of the code:
The scripts are from the
Scraplinglibrary bypasses folder: https://github.com/D4Vinci/Scrapling/tree/main/scrapling/engines/toolbelt/bypassesWhile creating this code for you I discovered that the issue is caused by
page.add_init_scriptif more than 1 script is used, I tried disabling all scripts and enabling each one alone but the error didn't happen so the error occurs when more than one script gets injected withpage.add_init_script.Tested the same code without
page.add_init_scriptand no error.Tested the same code but with pure playwright and no error.
vlrevolution commentedon Dec 8, 2024
Are those scripts really needed? It seems duplicate code to what rebrowser is already doing
D4Vinci commentedon Dec 8, 2024
@vlrevolution That is Not true, these scripts add a lot that current patches are not doing but still, if anyone uses
page.add_init_scripttwice then the issue will happen so there's no point in dodging the current issuevlrevolution commentedon Dec 8, 2024
I see and yeah of course, it was off beat, the root issue remains
D4Vinci commentedon Dec 10, 2024
Hey @nwebson @vlrevolution any updates on this?
nwebson commentedon Dec 10, 2024
Thanks for reporting this bug, just fixed it in the new release:
https://github.com/rebrowser/rebrowser-patches/releases/tag/1.0.17
D4Vinci commentedon Dec 10, 2024
Thanks @nwebson I have just tested it as well