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

set_browser_env times out when called from a Jupyter notebook #352

Open
benber86 opened this issue Dec 3, 2024 · 2 comments
Open

set_browser_env times out when called from a Jupyter notebook #352

benber86 opened this issue Dec 3, 2024 · 2 comments

Comments

@benber86
Copy link
Contributor

benber86 commented Dec 3, 2024

Trying to use set_browser_env in Jupyter will raise a TimeOutError.
Tested on Jupyter 7.2.2 and JupyterLab 4.0.7 (via try.vyperlang.org).
The same issue does not happen on Google Colab

import boa
%load_ext boa.ipython
boa.set_browser_env() 

results in:

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
Cell In[1], line 3
      1 get_ipython().run_line_magic('load_ext', 'boa.ipython')
      2 import boa
----> 3 boa.set_browser_env()

File /opt/conda/lib/python3.11/site-packages/boa/__init__.py:53, in set_browser_env(address)
     50 # import locally because jupyter is generally not installed
     51 from boa.integrations.jupyter import BrowserEnv
---> 53 set_env(BrowserEnv(address))

File /opt/conda/lib/python3.11/site-packages/boa/integrations/jupyter/browser.py:139, in BrowserEnv.__init__(self, address, **kwargs)
    137 def __init__(self, address=None, **kwargs):
    138     super().__init__(rpc=BrowserRPC(), **kwargs)
--> 139     self.signer = BrowserSigner(address)
    140     self.set_eoa(self.signer)

File /opt/conda/lib/python3.11/site-packages/boa/integrations/jupyter/browser.py:59, in BrowserSigner.__init__(self, address)
     54 """
     55 Create a BrowserSigner instance.
     56 :param address: The account address. If not provided, it will be requested from the browser.
     57 """
     58 address = getattr(address, "address", address)
---> 59 address = _javascript_call(
     60     "loadSigner", address, timeout_message=ADDRESS_TIMEOUT_MESSAGE
     61 )
     62 self.address = Address(address)

File /opt/conda/lib/python3.11/site-packages/boa/integrations/jupyter/browser.py:185, in _javascript_call(js_func, timeout_message, *args)
    183     hide_output_element = "element.style.display = 'none';"
    184     display(Javascript(js_code + hide_output_element))
--> 185     message_bytes = _wait_buffer_set(memory.buf, timeout_message)
    186     return _parse_js_result(json.loads(message_bytes.decode()))
    187 finally:

File /opt/conda/lib/python3.11/site-packages/boa/integrations/jupyter/browser.py:216, in _wait_buffer_set(buffer, timeout_message)
    214 future = _async_wait(deadline=loop.time() + CALLBACK_TOKEN_TIMEOUT.total_seconds())
    215 task = loop.create_task(future)
--> 216 loop.run_until_complete(task)
    217 return task.result()

File /opt/conda/lib/python3.11/site-packages/nest_asyncio.py:99, in _patch_loop.<locals>.run_until_complete(self, future)
     96 if not f.done():
     97     raise RuntimeError(
     98         'Event loop stopped before Future completed.')
---> 99 return f.result()

File /opt/conda/lib/python3.11/asyncio/futures.py:203, in Future.result(self)
    201 self.__log_traceback = False
    202 if self._exception is not None:
--> 203     raise self._exception.with_traceback(self._exception_tb)
    204 return self._result

File /opt/conda/lib/python3.11/asyncio/tasks.py:277, in Task.__step(***failed resolving arguments***)
    273 try:
    274     if exc is None:
    275         # We use the `send` method directly, because coroutines
    276         # don't have `__iter__` and `__next__` methods.
--> 277         result = coro.send(None)
    278     else:
    279         result = coro.throw(exc)

File /opt/conda/lib/python3.11/site-packages/boa/integrations/jupyter/browser.py:208, in _wait_buffer_set.<locals>._async_wait(deadline)
    206 while buffer.tobytes().startswith(NUL):
    207     if inner_loop.time() > deadline:
--> 208         raise TimeoutError(timeout_message)
    209     await sleep(0.01)
    211 return buffer.tobytes().split(NUL)[0]

TimeoutError: Timeout loading browser browser wallet plug-in.
@DanielSchiavini
Copy link
Collaborator

Do you see any errors in the browser console tab? What kind of wallet are you using? Did you get a pop-up at all to connect the site?

@benber86
Copy link
Contributor Author

image
no popups at all, tried with both rabby & metamask. windows + chrome, linux + ungoogled chromium

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

2 participants