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

[Bug]: AttributeError: 'WebError' object has no attribute '_dispatcher_fiber' #2706

Open
tgz-cz opened this issue Jan 3, 2025 · 0 comments

Comments

@tgz-cz
Copy link

tgz-cz commented Jan 3, 2025

Version

1.49.1

Steps to reproduce

My test-bug.py script:

from playwright.sync_api import sync_playwright

def run(playwright):
    browser = playwright.chromium.launch()
    context = browser.new_context()
    context.on("weberror", lambda error: Exception(f"My page error: {error=}"))

    page = context.new_page()

    page.set_content("""
        <script>var x=null;</script>
        <div><button onclick="x.myattr('xxx')">Click me</button></div>
    """)
    page.get_by_role("button").click()

with sync_playwright() as playwright:
    run(playwright)

Expected behavior

The callback:

  lambda error: Exception(f"My page error: {error=}")

should be called with the "javascript error from the page"

Actual behavior

The following exception is raised:

  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 453, in dispatch
    g.switch(self._replace_guids_with_channels(params))
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_connection.py", line 444, in _listener_with_error_handler_attached
    potential_future = listener(params)
                       ^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_browser_context.py", line 170, in <lambda>
    lambda params: self._on_page_error(
                   ^^^^^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_browser_context.py", line 695, in _on_page_error
    self.emit(BrowserContext.Events.WebError, WebError(self._loop, page, error))
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/base.py", line 212, in emit
    handled = self._call_handlers(event, args, kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/base.py", line 188, in _call_handlers
    self._emit_run(f, args, kwargs)
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/asyncio.py", line 53, in _emit_run
    self.emit("error", exc)
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/base.py", line 215, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/base.py", line 173, in _emit_handle_potential_error
    raise error
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/pyee/asyncio.py", line 51, in _emit_run
    coro: Any = f(*args, **kwargs)
                ^^^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_impl_to_api_mapping.py", line 124, in wrapper_func
    *list(map(lambda a: self.from_maybe_impl(a), args))[:arg_count]
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_impl_to_api_mapping.py", line 124, in <lambda>
    *list(map(lambda a: self.from_maybe_impl(a), args))[:arg_count]
                        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_impl_to_api_mapping.py", line 69, in from_maybe_impl
    api_instance = api_class(obj)
                   ^^^^^^^^^^^^^^
  File "/home/developer/.cache/pypoetry/virtualenvs/testbug-i1-BfjSz-py3.11/lib/python3.11/site-packages/playwright/_impl/_sync_base.py", line 92, in __init__
    self._dispatcher_fiber = impl_obj._dispatcher_fiber
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'WebError' object has no attribute '_dispatcher_fiber'

Additional context

Environment

- Operating System: Linux / docker image debian:bullseye-slim
- CPU: AMD Ryzen
- Browser: Chromium
- Python Version: 3.11.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant