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

CDP server issues on MacOS (m2) #339

Open
addy999 opened this issue Dec 19, 2024 · 4 comments
Open

CDP server issues on MacOS (m2) #339

addy999 opened this issue Dec 19, 2024 · 4 comments
Labels
bug Something isn't working CDP Chrome Debug Protocol

Comments

@addy999
Copy link

addy999 commented Dec 19, 2024

Running the nightly build and connecting via puppeteer from another terminal:

Terminal 1

./lightpanda-aarch64-macos --host 127.0.0.1 --port 9222
> info(websocket): starting blocking worker to listen on 127.0.0.1:9222
> info(server): accepting new conn...
> info(server): client connected
> info(server): accepting new conn...
> error(handler): stream close error: error.BrokenPipe

Terminal 2:

In [1]: from pyppeteer import launch, connect

In [2]: b = await connect(browserURL="http://127.0.0.1:9222")

In [3]: page = await b.newPage()
---------------------------------------------------------------------------
NetworkError                              Traceback (most recent call last)
Cell In[3], line 1
----> 1 page = await b.newPage()

File ~/miniconda3/lib/python3.11/site-packages/pyppeteer/browser.py:202, in Browser.newPage(self)
    200 async def newPage(self) -> Page:
    201     """Make new page on this browser and return its object."""
--> 202     return await self._defaultContext.newPage()

File ~/miniconda3/lib/python3.11/site-packages/pyppeteer/browser.py:358, in BrowserContext.newPage(self)
    356 async def newPage(self) -> Page:
    357     """Create a new page in the browser context."""
--> 358     return await self._browser._createPageInContext(self._id)

File ~/miniconda3/lib/python3.11/site-packages/pyppeteer/browser.py:209, in Browser._createPageInContext(self, contextId)
    206 if contextId:
    207     options['browserContextId'] = contextId
--> 209 targetId = (await self._connection.send(
    210     'Target.createTarget', options)).get('targetId')
    211 target = self._targets.get(targetId)
    212 if target is None:

NetworkError: Protocol error Target.createTarget: Target closed.
@krichprollsch krichprollsch added bug Something isn't working CDP Chrome Debug Protocol labels Dec 19, 2024
@krichprollsch
Copy link
Member

Hello @addy999
Thank you for your bug report.

Can you retry with --verbose option on ligthpanda please?

@krichprollsch
Copy link
Member

Here is what I reproduce with the following gist https://gist.github.com/krichprollsch/f510c3c89a21dd70e406a9c79f3b3b06
@addy999 is it accurate? I'm not used to using python...

$ docker run --rm -ti --privileged lpd:issue339
//issue339.py:8: DeprecationWarning: There is no current event loop
  asyncio.get_event_loop().run_until_complete(main())
Traceback (most recent call last):
  File "//issue339.py", line 8, in <module>
    asyncio.get_event_loop().run_until_complete(main())
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "//issue339.py", line 6, in main
    page = await b.newPage()
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyppeteer/browser.py", line 202, in newPage
    return await self._defaultContext.newPage()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyppeteer/browser.py", line 358, in newPage
    return await self._browser._createPageInContext(self._id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyppeteer/browser.py", line 213, in _createPageInContext
    raise BrowserError('Failed to create target for page.')
pyppeteer.errors.BrowserError: Failed to create target for page.
debug(cli): Server opts: listening internally on /tmp/lightpanda...
info(websocket): starting blocking worker to listen on 127.0.0.1:9222
info(server): accepting new conn...
debug(websocket): (127.0.0.1:43946) connected
debug(websocket): (127.0.0.1:43952) connected
debug(handler): connected to Stream server
info(server): client connected
debug(websocket): (127.0.0.1:43952) connection successfully upgraded
debug(websocket): (127.0.0.1:43952) received text message
debug(cdp): Req > id 1, method target.getBrowserContexts
debug(cdp): Res > id 1, sessionID null, result cdp.target.getBrowserContexts.Resp{ .browserContextIds = {  } }
debug(websocket): (127.0.0.1:43952) received text message
debug(cdp): Req > id 2, method target.setDiscoverTargets
debug(cdp): Res > id 2, sessionID null, result null
debug(websocket): (127.0.0.1:43952) received text message
debug(cdp): Req > id 3, method target.createTarget
debug(cdp): Event > method Target.attachedToTarget, sessionID null
debug(cdp): Res > id 3, sessionID null, result cdp.target.createTarget { .targetId = 57356548460A8F29706A2ADF14316298 }
debug(websocket): (127.0.0.1:43952) connection closed: error.Closed
info(server): close cmd, closing conn...
debug(server): connection closed
info(server): accepting new conn...
debug(server): read has been canceled

@addy999
Copy link
Author

addy999 commented Dec 19, 2024

Okay I did it with --verbose

debug(handler): connected to Stream server
info(server): client connected
debug(websocket): (127.0.0.1:61253) connection successfully upgraded
debug(websocket): (127.0.0.1:61253) received text message
debug(cdp): Req > id 1, method target.getBrowserContexts
debug(cdp): Res > id 1, sessionID null, result cdp.target.getBrowserContexts.Resp{ .browserContextIds = {  } }
debug(websocket): (127.0.0.1:61253) received text message
debug(cdp): Req > id 2, method target.setDiscoverTargets
debug(cdp): Res > id 2, sessionID null, result null
debug(websocket): (127.0.0.1:61253) received text message
debug(cdp): Req > id 3, method target.createTarget
debug(cdp): Event > method Target.attachedToTarget, sessionID null
debug(cdp): Res > id 3, sessionID null, result cdp.target.createTarget { .targetId = 57356548460A8F29706A2ADF14316298 }

Now I'm seeing a TegetError

----> 1 page = await b.newPage()

File ~/.pyenv/versions/3.10.10/lib/python3.10/site-packages/pyppeteer/browser.py:202, in Browser.newPage(self)
    200 async def newPage(self) -> Page:
    201     """Make new page on this browser and return its object."""
--> 202     return await self._defaultContext.newPage()

File ~/.pyenv/versions/3.10.10/lib/python3.10/site-packages/pyppeteer/browser.py:358, in BrowserContext.newPage(self)
    356 async def newPage(self) -> Page:
    357     """Create a new page in the browser context."""
--> 358     return await self._browser._createPageInContext(self._id)

File ~/.pyenv/versions/3.10.10/lib/python3.10/site-packages/pyppeteer/browser.py:213, in Browser._createPageInContext(self, contextId)
    211 target = self._targets.get(targetId)
    212 if target is None:
--> 213     raise BrowserError('Failed to create target for page.')
    214 if not await target._initializedPromise:
    215     raise BrowserError('Failed to create target for page.')

BrowserError: Failed to create target for page.

@krichprollsch
Copy link
Member

ok thank you, I think I have what I need to start debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CDP Chrome Debug Protocol
Projects
None yet
Development

No branches or pull requests

2 participants