Skip to content
New issue

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

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

Already on GitHub? # to your account

[Bug]: Future finished exception=TargetClosedError('Target page, context or browser has been closed') #2426

Closed
jmrodri opened this issue May 2, 2024 · 0 comments · Fixed by #2427

Comments

@jmrodri
Copy link

jmrodri commented May 2, 2024

Version

1.43.0

Steps to reproduce

Example steps (replace with your own):

  1. Clone my repo at https://github.com//example
  2. pip install -r requirements.txt
  3. python main.py
  4. You should see the error come up
$ python main.py
status_code 200 | url http://httpbin.org/status/200
Future exception was never retrieved
future: <Future finished exception=TargetClosedError('Target page, context or browser has been closed')>
playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed

Expected behavior

I expect NOT to see any error.

Actual behavior

Future exception was never retrieved message being printed.

Additional context

Enabling PYTHONASYNCIODEBUG=1 gives more information:

$ export PYTHONASYNCIODEBUG=1
$ python main.py
status_code 200 | url http://httpbin.org/status/200
Future exception was never retrieved
future: <Future finished exception=TargetClosedError('Target page, context or browser has been closed') created at /home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py:427>
source_traceback: Object created at (most recent call last):
  File "/home/jesusr/dev/swiftline/pw-future-error/main.py", line 46, in <module>
    asyncio.run(main())
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 640, in run_until_complete
    self.run_forever()
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 607, in run_forever
    self._run_once()
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 1914, in _run_once
    handle._run()
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/jesusr/dev/swiftline/pw-future-error/main.py", line 42, in main
    await fetch("http://httpbin.org/status/200", "ws://localhost:3000/playwright/chromium")
  File "/home/jesusr/dev/swiftline/pw-future-error/main.py", line 37, in fetch
    response = await browser.close()
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/async_api/_generated.py", line 13658, in close
    return mapping.from_maybe_impl(await self._impl_obj.close(reason=reason))
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_browser.py", line 184, in close
    await self._connection.stop_async()
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 283, in stop_async
    self._transport.request_stop()
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_json_pipe.py", line 39, in request_stop
    self._pipe_channel.send_no_reply("close", {})
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 70, in send_no_reply
    self._connection.wrap_api_call_sync(
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 527, in wrap_api_call_sync
    return cb()
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 71, in <lambda>
    lambda: self._connection._send_message_to_server(
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 322, in _send_message_to_server
    callback = ProtocolCallback(self._loop)
  File "/home/jesusr/.pyenv/versions/pw-future-error/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 187, in __init__
    self.future = loop.create_future()
  File "/home/jesusr/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 427, in create_future
    return futures.Future(loop=self)
playwright._impl._errors.TargetClosedError: Target page, context or browser has been closed

Environment

- Operating System: [Debian GNU/Linux 12 (bookworm), Arch Linux]
- CPU: [x86_64]
- Browser: [Chromium]
- Python Version: [3.11.4]
- Other info: ghcr.io/browserless/chromium:latest
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant