mamba-org/gator

"Internal server error" while leaving Conda tab open

dnabb opened this issue · 3 comments

dnabb commented

Description

Using the classical notebook, I have the jupyter_conda extension tab open in one browser tab while working on a notebook in another browser tab.

When returning to the jupyter_conda extension tab after a while, I sometimes see the following error:

An error occurred while retrieving package information.
Internal Server Error

Once the error is acknowledged, everything seems to be working fine for a while, until the error appears again.

Reproduce

  1. Open Jupyter Notebook and open a notebook in another browser tab
  2. On the main Jupyter Notebook, go to the Conda extension tab and leave it open
  3. Work in the open notebook for a while
  4. See the error

Expected behavior

No errors should appear.

Context

  • Python package version:
    jupyter_conda 3.2.0

  • General information:

active environment : myenv
    active env location : C:\Users\my_user\anaconda3\envs\myenv
            shell level : 2
       user config file : C:\Users\my_user\.condarc
 populated config files : C:\Users\my_user\.condarc
          conda version : 4.8.3
    conda-build version : 3.18.11
         python version : 3.7.6.final.0
       virtual packages :
       base environment : C:\Users\my_user\anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/danabb/win-64
                          https://conda.anaconda.org/danabb/noarch
                          https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\my_user\anaconda3\pkgs
                          C:\Users\my_user\.conda\pkgs
                          C:\Users\my_user\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\my_user\anaconda3\envs
                          C:\Users\my_user\.conda\envs
                          C:\Users\my_user\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.8.3 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.18362
          administrator : False
             netrc file : None
           offline mode : False
Command Line Output
[jupyter_conda] Error for task {'type': 'JSONDecodeError', 'error': 'Expecting value: line 1 column 1 (char 0)', 'message': "JSONDecodeError('Expecting value: line 1 column 1 (char 0)')", 'traceback': ['  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\site-packages\\jupyter_conda\\handlers.py", line 99, in execute_task\n    result = await f(*args)\n', '  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\site-packages\\jupyter_conda\\handlers.py", line 378, in update_available\n    answer = await env_manager.list_available()\n', '  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\site-packages\\jupyter_conda\\envmanager.py", line 536, in list_available\n    pkg_info.update(json.loads(channeldata)["packages"])\n', '  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\json\\__init__.py", line 348, in loads\n    return _default_decoder.decode(s)\n', '  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\json\\decoder.py", line 337, in decode\n    obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n', '  File "C:\\Users\\my_user\\anaconda3\\envs\\myenv\\lib\\json\\decoder.py", line 355, in raw_decode\n    raise JSONDecodeError("Expecting value", s, err.value) from None\n']}.
[E 14:49:33.808 NotebookApp] {
      "Host": "localhost:8889",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0",
      "Accept": "application/json, text/javascript, */*; q=0.01",
      "Accept-Language": "en,en-US;q=0.5",
      "Accept-Encoding": "gzip, deflate",
      "Content-Type": "application/json",
      "X-Xsrftoken": "2|45dd5af5|7da671fcd92d13cf1ab8bdd307663521|1588788619",
      "X-Requested-With": "XMLHttpRequest",
      "Connection": "keep-alive",
      "Referer": "http://localhost:8889/tree/%40Testing/myenv%26sos",
      "Cookie": "username-localhost-8888=\"2|1:0|10:1589290483|23:username-localhost-8888|44:ODQ4OGZjNzRiOGE2NDVjMzgyNDI3NTNiNmEzNTk4Yjg=|512f4bb20310ee5918647e5237331a01c6944f967ac323ad655966774364d137\"; username-localhost-8889=\"2|1:0|10:1589373875|23:username-localhost-8889|44:MmExZDFjNzdlMTEyNDEyMzg5OGVlNzViNWE0MjU1YmM=|d79c33879223d7d013ef917580a96196f56ea565900c6aa5287c61c898360055\"; username-localhost-8890=\"2|1:0|10:1589312521|23:username-localhost-8890|44:MDE5NjQ1NWMwZTgzNGY3OGE0ZTE5ZTY5YjM4Yjk0NzQ=|339aff3272598c4137b2fa9cdd8ab45ba208520b05a1dbdea4a6ffddbfb16f08\"; _xsrf=2|45dd5af5|7da671fcd92d13cf1ab8bdd307663521|1588788619; username-localhost-8891=\"2|1:0|10:1589372152|23:username-localhost-8891|44:MmYyMjhkZjQ0NWVhNDZjZTg2NmZjNzY1NTIyN2ZhZGY=|64da50ba72388c7d4c053768d6be093caf94a71448ea122ea5a3d3efb2954734\"; username-localhost-8892=\"2|1:0|10:1589312815|23:username-localhost-8892|44:MGUzMTAzMDc3ZjEzNDBhZTg0YmYwOTg0NjVhZTA4YTI=|e91747578f41edd9a44d626aea5479aab08091c1bc81127a4578884887c4333c\""
    }
[E 14:49:33.813 NotebookApp] 500 GET /conda/tasks/1?_=1589373876385 (127.0.0.1) 2.00ms referer=http://localhost:8889/tree/%40Testing/myenv%26sos
Browser Output
Paste the output from your browser Javascript console here.

@dabbatelli Thanks for the detailed reported bug.

Could you try a "dirty" patch on your computer?

On your computer, could you modify the line:
File "C:\Users\my_user\anaconda3\envs\myenv\lib\site-packages\jupyter_conda\envmanager.py", line 536

with the following patch

-                    pkg_info.update(json.loads(channeldata)["packages"])
+                    try
+                        pkg_info.update(json.loads(channeldata)["packages"])
+                    except json.JSONDecodeError as err:
+                        self.log.info("[jupyter_conda] Error getting {}/channeldata.json: {}".format(channel, str(e))

The error should be stopped at the server side. So in the terminal the new log information message should appears. Could you then reported here?

To give you more information, the error comes from your customized channel danabb. The extension is looking for package url and description in a file called channeldata.json stored in conda channels. But it appears to be missing in the one you specified. But the conda server is still replying the request with an HTML file and not a JSON file. And so you go your error.

dnabb commented

Hello @fcollonval

Had to do some small adjustments but it works :)
My code is now:

                    try:
                        pkg_info.update(json.loads(channeldata)["packages"])
                    except json.JSONDecodeError as e:
                        self.log.info("[jupyter_conda] Error getting {}/channeldata.json: {}".format(channel, str(e)))

No errors come up in the conda tab, but the console reports it as:
[I 16:50:38.261 NotebookApp] [jupyter_conda] Error getting https://conda.anaconda.org/danabb/channeldata.json: Expecting value: line 1 column 1 (char 0)

Thanks for trying the patch @dabbatelli and glad it fixes your error - after your corrections 😉

I am gonna push it - and some smaller adjustments - before releasing a new version