kiyoon / jupynium.nvim

Selenium-automated Jupyter Notebook that is synchronised with NeoVim in real-time.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jupynium crashes if more than one tab at startup

vandalt opened this issue · comments

Hi, thanks for this plugin! I had a small issue when running with some extensions as described below.

Describe the bug
If there is more than one tab in the browser window when jupynium starts, it hangs and crashes with a timeout error.
This is a bit of an edge case, but it happened to me in a firefox profile where new tab was managed by an extension (tridactyl). This opened a second tab automatically.

To Reproduce
Steps to reproduce the behavior:

  1. Launch Jupynium with :JupyniumStartAndAttachToServerInTerminal
  2. Wait 10 seconds
  3. Jupynium terminal fails with message shown below
jupynium.cmds.jupynium:  520 - ERROR - Exception occurred
Traceback (most recent call last):
  File "/home/vandal/.local/lib/python3.10/site-packages/jupynium/cmds/jupynium.py", line 461, in main
    driver_wait.until(EC.number_of_windows_to_be(1))
  File "/usr/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

jupynium.cmds.jupynium:  321 - INFO - Jupyter Notebook server (pid=29665) has been killed.

Expected behavior
I would expect either Jupynium works normally if there is more than one tab in the window it starts in, or the incompatibility to be documented somewhere. The simplest fix was of course to change the new tab to default in the profile used by jupynium, but I think Jupynium can be made more generic relatively simply (see "Additional context"). The latter option would enable more flexible workflows for users.

Output of jupynium --version

Jupynium v0.1.2.dev51+gb79a625

Output of nvim --version

NVIM v0.8.3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Additional context
The lines of code involved are the following:

driver_wait = WebDriverWait(driver, 10)
driver_wait.until(EC.number_of_windows_to_be(1))

I tried replacing the EC.number_of_windows_to_be by a function that checks "greater than 1" instead of "equal to 1" and it seems to fix the issue. I can send a PR if you want.

Hi, I personally don't use the the profile so I didn't know this. Thanks! I think a better fix would be to get the number of windows already opened before the startup, and check if it matches the number +1. PR would be grateful, or you can wait for a day or two until I address this.

If you go for PR please include a comment explaining why it's not 1 and it can be more opened when you use a profile. Thanks!

Does Jupynium start from an existing firefox browser opening a new tab? Even if I set the firefox profiles and keep firefox running, for me jupynium just opens a new browser. How did you configure this?

@vandalt Never mind, I misunderstood you, thinking that jupynium would use an existing browser. Now I get it that some plugins open pages or you can set multiple home pages.