microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

pytest run shows no output, gets in connection error infinite loop #22192

Closed underyx closed 1 year ago

underyx commented 1 year ago

Note this is a bug report, but the built-in dialog for bug reports was broken.

Behaviour

Expected vs. Actual

Tests used to run when I clicked the play button in the test explorer but sometime within the last few weeks the whole integration broke.

Steps to reproduce:

  1. Trigger a pytest run in the test explorer

https://github.com/microsoft/vscode-python/assets/1060436/7cfc9f2e-2cf2-4a93-821f-0ffc8196c2a4

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

``` XXX ```

User Settings

``` languageServer: "Pylance" ``` ``` "python.testing.cwd": "./server", "python.testing.pytestArgs": [ "-p", "no:cov", "-p", "no:ddtrace", "-p", "no:ddtrace.pytest_bdd", "-p", "no:xdist" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, ```

A/B test info

vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263:30856252
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
f6dab269:30613381
showlangstatbar:30737416
962ge761:30841074
03d35959:30757346
57b77579:30736110
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
dsvsc013:30795093
dsvsc014:30804076
diffeditorv1:30821571
dsvsc015:30845448
eleanorjboyd commented 1 year ago

Hi! Could you send over the configuration of your machine? It seems you might be using a server? Additionally, can you copy the whole python logs and include them? It looks like you are on the new testing rewrite we are rolling out but hitting the error "Plugin error connection error". This occurs when we attempt to send the data from the subprocess we spin up back to the extension on a port. This could have happened because the socket couldn't connect or because the data couldn't be processed to be sent.

eleanorjboyd commented 1 year ago

also in what way was the built-in dialog for bug reports broken? Seeing it still working on my end, thanks

underyx commented 1 year ago

Here's all my python logs after launching vscode, waiting for tests to be discovered, and trying to run one test (triggering the infinite loop):

2023-10-11 11:07:07.590 [info] Experiment 'python.createEnvironment.trigger' is active
2023-10-11 11:07:07.590 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-10-11 11:07:07.590 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-10-11 11:07:07.590 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2023-10-11 11:07:07.590 [info] Experiment 'pythonTestAdapter' is active
2023-10-11 11:07:07.590 [info] Test server listening.
2023-10-11 11:07:07.590 [info] Python interpreter path: ./server/.venv/bin/python
2023-10-11 11:07:09.422 [info] > conda info --json
2023-10-11 11:07:09.539 [info] > . ./server/.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
2023-10-11 11:07:09.539 [info] shell: zsh
2023-10-11 11:07:09.722 [info] > ~/.conda/bin/conda info --json
2023-10-11 11:07:09.730 [info] > . ./server/.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
2023-10-11 11:07:09.731 [info] shell: bash
2023-10-11 11:07:09.744 [info] > /usr/bin/python3 ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/printEnvVariables.py
2023-10-11 11:07:09.744 [info] shell: zsh
2023-10-11 11:07:09.757 [info] > ./server/.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/linter.py -m mypy --python-version=3.11 ./server/semgrep_app/cloud_platform/auth/models/user_invites.py
2023-10-11 11:07:09.757 [info] cwd: ./server
2023-10-11 11:07:09.764 [info] > /opt/homebrew/anaconda3/bin/conda info --json
2023-10-11 11:07:11.164 [info] Starting Pylance language server.
2023-10-11 11:07:13.118 [info] ##########Linting Output - mypy##########

2023-10-11 11:07:13.118 [info] Success: no issues found in 1 source file

2023-10-11 11:07:16.313 [info] Discover tests for workspace name: app - uri: /Users/underyx/r2c/app
2023-10-11 11:07:16.313 [info] Running discovery for pytest using the new test adapter.
2023-10-11 11:07:16.315 [info] > ./server/.venv/bin/python -m pytest -p vscode_pytest --collect-only -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
2023-10-11 11:07:16.315 [info] cwd: ./server
2023-10-11 11:07:28.224 [info] Test server connected to a client.
2023-10-11 11:07:28.354 [info] ResultResolver EOT received for discovery.
2023-10-11 11:07:29.461 [info] Disposing data receiver for /Users/underyx/r2c/app and deleting UUID; pytest discovery.
2023-10-11 11:07:36.417 [info] Server listening on port 51114
2023-10-11 11:07:36.419 [info] Running pytest with arguments: /Users/underyx/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir /Users/underyx/r2c/app -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist

2023-10-11 11:07:36.419 [info] > ./server/.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.18.0/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir . -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
2023-10-11 11:07:36.419 [info] cwd: ./server

The test logs, in copy-pastable form:

[vscode-pytest] data: Content-Length: 430
Content-Type: application/json
Request-uuid: None

{"cwd": "/Users/underyx/r2c/app/server", "status": "success", "result": {"/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates": {"test": "/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
Plugin error connection error[vscode-pytest]
[vscode-pytest] data: Content-Length: 430
Content-Type: application/json
Request-uuid: None

{"cwd": "/Users/underyx/r2c/app/server", "status": "success", "result": {"/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates": {"test": "/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
Plugin error connection error[vscode-pytest]
[vscode-pytest] data: Content-Length: 430
Content-Type: application/json
eleanorjboyd commented 1 year ago

it should retry 5 times, do you think it went longer than that when running? Curious how long this loop is and if it ever ends. Also if you click the cancel button does this work to end the looping?

What again is your machine type and setup? Are you on a remote machine or connected via ssh?

underyx commented 1 year ago

As for my machine configuration, I'm using vscode on macOS. I'm developing locally, it's just that there's a directory called server/ in my repository.

With the builtin bug report feature, pressing the Submit button was not doing anything for me. This might be related to API rate limits because when I was writing a title for my report, I got 'similar issues' suggestions a few times until the suggestions were replaced with a 'GitHub rate limit exceeded' message.

The test logs loop infinitely very quickly. In the ten minutes since my previous comment these five lines have been printed at least 20,000 times.

eleanorjboyd commented 1 year ago

do you have any firewall rule that might be preventing socket from connecting?

underyx commented 1 year ago

unlikely, the only firewall I have enabled is the macOS system one, which doesn't seem to have any blocking on local connections, and most things seem to be allowed through:

CleanShot 2023-10-11 at 12 00 35@2x

CleanShot 2023-10-11 at 12 00 44@2x

I also don't really run into similar issues with any other extensions or apps trying to communicate with ports on localhost.

eleanorjboyd commented 1 year ago

Hi! I see from your logs that the UUID for the given run is not being defined. It seems that the environment variables the extension sets are somehow not read correctly / applied to the subprocess. Can you confirm that you have something like this in your "Python" logs Test server connected to a client. if your log level is set to info? Otherwise, any issues occurred in the past with environment variables? Such as the user not being defined?

Thank you again for all your help!! I really appreciate it

eleanorjboyd commented 1 year ago

Also can you send what version of the extension you are on?

underyx commented 1 year ago

I use v2023.18.0 of ms-python.python. It seems like the line we're looking for shows up in the log snippet above: 2023-10-11 11:07:28.224 [info] Test server connected to a client. — the log snippet has a lot of [info] lines and this is what "Set log level" shows:

CleanShot 2023-10-11 at 16 04 04@2x

I never had issues with environment variables as far as I could tell. I did have a weird bug on the mypy extension before but I don't think that was environment related: https://github.com/microsoft/vscode-mypy/issues/85

eleanorjboyd commented 1 year ago

hm will continue to investigate, thought it was related to this PR: https://github.com/microsoft/vscode-python/commit/e7dfef8f5ed9f9b59b75fd9d0d64118734224bdd but that was merged after we cut the 2023.18.0 version.

eleanorjboyd commented 1 year ago

Hello! Is there any chance you could try the newest release of vscode insiders? I have pushed a change with logging that would help me identify the root cause.

underyx commented 1 year ago

@eleanorjboyd I updated the Python extension to pre-release v2023.19.12891009, but I'm still using the stable vscode 1.83.1.

The infinitely looping logs have moved from Output > Python to the Test Results tab. These two lines are printed on the Test Results before the error loop starts:

CLIENT: Server listening on port 56275...
Received JSON data in run script

This is what I see on Output > Python now:

[... successful pytest discovery output ...]
======================== 1953 tests collected in 4.21s =========================

2023-10-16 14:07:48.466 [info] Disposing data receiver for /Users/underyx/r2c/app and deleting UUID; pytest discovery.
2023-10-16 14:07:55.145 [info] Server listening on port 56275
2023-10-16 14:07:55.145 [info] All environment variables set for pytest execution: {"ASDF_DIR":"/Users/underyx/.zinit/plugins/asdf-vm---asdf","CAML_LD_LIBRARY_PATH":"/Users/underyx/.opam/4.14.0/lib/stublibs:/Users/underyx/.opam/4.14.0/lib/ocaml/stublibs:/Users/underyx/.opam/4.14.0/lib/ocaml","COLORFGBG":"15;0","COLORTERM":"truecolor","COMMAND_MODE":"unix2003","CPATH":":/opt/homebrew/include","DB_EVENT_BUS":"db-events-bus-dev","DD_TRACE_ENABLED":"false","DIRENV_DIFF":"[... redacted ...]","DIRENV_DIR":"-/Users/underyx/r2c/app/server","DIRENV_FILE":"/Users/underyx/r2c/app/server/.envrc","DIRENV_WATCHES":"[... redacted ...]","EDITOR":"/usr/bin/vim","ELECTRON_NO_ATTACH_CONSOLE":"1","FLASK_APP":"semgrep_app/app.py","FLASK_ENV":"development","GOPATH":"/Users/underyx/go","GPG_TTY":"/dev/ttys000","HISTFILE":"/Users/underyx/.zsh_history","HISTSIZE":"100000","HIST_IGNORE_SPACE":"1","HOME":"/Users/underyx","ITERM_PROFILE":"Default","ITERM_SESSION_ID":"w0t1p0:1A2FBE8F-6192-40C6-A989-1B36B3015B12","JAVA_HOME":"/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home","KEYTIMEOUT":"1","LANG":"en_US.UTF-8","LC_ALL":"en_US.UTF-8","LC_TERMINAL":"iTerm2","LC_TERMINAL_VERSION":"3.4.20","LIBRARY_PATH":":/opt/homebrew/lib","LOGNAME":"underyx","MallocNanoZone":"0","OCAML_TOPLEVEL_PATH":"/Users/underyx/.opam/4.14.0/lib/toplevel","OPAM_SWITCH_PREFIX":"/Users/underyx/.opam/4.14.0","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","PIPENV_VENV_IN_PROJECT":"true","PKG_CONFIG_PATH":"/Users/underyx/.opam/4.14.0/lib/pkgconfig:","PMSPEC":"0uUpiPsf","PNPM_HOME":"/Users/underyx/Library/pnpm","PWD":"/Users/underyx/r2c/app/server","SAVEHIST":"100000","SHELL":"/bin/zsh","SHLVL":"2","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.hStlPDRC7I/Listeners","STARSHIP_SESSION_KEY":"1210613912229751","STARSHIP_SHELL":"zsh","TERM":"xterm-256color","TERM_PROGRAM":"iTerm.app","TERM_PROGRAM_VERSION":"3.4.20","TERM_SESSION_ID":"w0t1p0:1A2FBE8F-6192-40C6-A989-1B36B3015B12","TMPDIR":"/var/folders/6m/1krt8ck117x_k5_yhh71sb5m0000gn/T/","USER":"underyx","VISUAL":"/usr/bin/vim","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CLI":"1","VSCODE_CODE_CACHE_PATH":"/Users/underyx/Library/Application Support/Code/CachedData/f1b07bd25dfad64b0167beb15359ae573aecd2cc","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/Users/underyx/r2c/app/server","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/Users/underyx/Library/Application Support/Code/1.83-main.sock","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"21765","XPC_FLAGS":"0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.183562817.183562823.0915B54F-BDCB-4EB8-8B30-F6D0ABDD97EA","ZPFX":"/Users/underyx/.zinit/polaris","ZSHHOME":"/Users/underyx/.zsh","ZSH_CACHE_DIR":"/Users/underyx/.zsh/.cache","__CFBundleIdentifier":"com.microsoft.VSCode","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","ELECTRON_RUN_AS_NODE":"1","PATH":"/Users/underyx/.zinit/plugins/starship---starship:/Users/underyx/.zinit/plugins/cli---cli/gh/bin:/Users/underyx/.zinit/plugins/sharkdp---fd/fd-v8.7.0-x86_64-apple-darwin:/Users/underyx/.zinit/plugins/BurntSushi---ripgrep/ripgrep-13.0.0-x86_64-apple-darwin:/Users/underyx/.zinit/plugins/sharkdp---bat/bat-v0.23.0-x86_64-apple-darwin:/Users/underyx/.zinit/plugins/junegunn---fzf:/Users/underyx/.zinit/plugins/dandavison---delta/delta-0.16.5-aarch64-apple-darwin:/Users/underyx/.zinit/plugins/direnv---direnv:/Users/underyx/Library/pnpm:/Users/underyx/.opam/4.14.0/bin:/Users/underyx/.asdf/shims:/Users/underyx/.zinit/plugins/asdf-vm---asdf/bin:/Users/underyx/.asdf/installs/python/3.12.0/bin:./node_modules/.bin:/Users/underyx/.cargo/bin:/Users/underyx/bin:/Users/underyx/.local/bin:/Users/underyx/go/bin:/opt/homebrew/bin:/usr/local/sbin:/Users/underyx/.zinit/polaris/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/underyx/.orbstack/bin","PYTHONPATH":"/Users/underyx/.vscode/extensions/ms-python.python-2023.19.12891009/pythonFiles","TEST_UUID":"8dd0828a-6700-4070-bbd8-79de5a325453","TEST_PORT":"56147","RUN_TEST_IDS_PORT":"56275"}
2023-10-16 14:07:55.145 [info] Running pytest with arguments: /Users/underyx/.vscode/extensions/ms-python.python-2023.19.12891009/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir /Users/underyx/r2c/app -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist

2023-10-16 14:07:55.146 [info] > ./server/.venv/bin/python ~/.vscode/extensions/ms-python.python-2023.19.12891009/pythonFiles/vscode_pytest/run_pytest_script.py --rootdir . -p no:cov -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:xdist
2023-10-16 14:07:55.146 [info] cwd: ./server

Note I have redacted a lot of env vars, because all my application secrets were printed there. I have fully removed around 20-30 keys where I didn't want to share the env var names publicly. I can share these names privately.

underyx commented 1 year ago

In the meantime, could you help me unenroll from the pythonTestAdapter experiment?

underyx commented 1 year ago

Never mind, found this setting:

  "python.experiments.optOutFrom": [
    "pythonTestAdapter"
  ]
eleanorjboyd commented 1 year ago

Hi! Glad you found that setting to opt out, and redacting the env vars is fine I only wanted to see if the TEST_PORT and TEST_UUID got set. Earlier you had a payload that got dumped to output like below, is this no longer happening? I would expect it would be both in the Test Result panel (like you said it moved to) and still existing in the Python test output channel like before just with a deprecation message.

[vscode-pytest] data: Content-Length: 430
Content-Type: application/json
Request-uuid: None

{"cwd": "/Users/underyx/r2c/app/server", "status": "success", "result": {"/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates": {"test": "/Users/underyx/r2c/app/server/tests/integration/cloud_platform/onboarding/test_checklist.py::test_checklist_updates", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
Plugin error connection error[vscode-pytest]
[vscode-pytest] data: Content-Length: 430
Content-Type: application/json
Request-uuid: None

I added in logging there and expected you to see the above payload again as well as maybe a message like Error[vscode-pytest]: TEST_UUID is not set..

Thank you again for your help I really appreciate it immensely.

alanwilter commented 1 year ago

I'm wondering if #21599 is not also linked somehow to this issue. I see several issues (e.g. #22218) with this new "Discovery tests...", apparently all different, but I'm starting to suspect they have the all the same source. In which ms-python.python was it it introduced? I'd like to revert to an old version without this new Discovery to have my pytest back working.

eleanorjboyd commented 1 year ago

Hi @alanwilter, sorry to hear you are facing a few issues. Same as above you can put in the following setting to revert to the old version.

"python.experiments.optOutFrom": [ "pythonTestAdapter" ]

Since you are having an issue with a multiroot workspace as you said here: https://github.com/microsoft/vscode-python/issues/22218 that is likely your issue. Are you getting any missing UUIDs or error messages that made you think it is connected to this issue as well? If you could upload both your "python" and "python test logs" this could help me narrow down the issue and would be much appreciated. Thanks

alanwilter commented 1 year ago

Hi @eleanorjboyd, thanks for your reply.

Indeed, the only remote vscode where tests were working was specifically the one with: ~/.vscode-server/data/Machine/settings.json (i.e. the remote setting.json)

with:

{
  "python.experiments.optOutFrom": ["pythonTestAdapter"]
}

I added this line to all my remote settings and now Test Explorer is working (using the old way).

I have noticed this before here: https://github.com/microsoft/vscode-python/issues/21599#issuecomment-1636746947

But since you asked for the logs (before I added the lines above):

Python log: https://github.com/microsoft/vscode-python/issues/22218#issuecomment-1764604962

Python Test Log (interestingly, it seems to find my tests, but Test Explorer won't change!):

Screenshot 2023-10-17 at 22 35 11
eleanorjboyd commented 1 year ago

Hi! So you think that this is an issue with the multiroot like I am fixing on the other PR or are you saying you don't think that applies in the given context? Thanks

alanwilter commented 1 year ago

I'm not sure anymore. Just saying that the new Discovery is not working for me, yet the Python Test Log indicates my pytest were found, they just don't get populated in the Test Explorer. I have this issue in local (Mac) and remote computer (linux).

The only way I get the Test Explorer is adding "python.experiments.optOutFrom": ["pythonTestAdapter"], to both setting.json user and remote.

jarek-webellian commented 1 year ago

Hi. We're experiencing the same issue. Here's what we've been able to find regarding combination of vscode and python extension versions:

eleanorjboyd commented 1 year ago

@jarek-webellian Could you send your "python" logs and "python test logs" for the scenario where you get stuck in the infinite loop? If you are able to switch to the "pre-release" version of the python extension and send the logs there that would be especially helpful as I have added some extra logging to help diagnose this issue. Thank you!

jarek-webellian commented 1 year ago

@eleanorjboyd Here's our simplest test case to reproduce it, stripped out of everything. It seems that our dubious practice of modifying env vars in tests is causing the issue 🙃

conftest.py

import os
from typing import Generator
from unittest import mock

import pytest

@pytest.fixture(autouse=True, scope="session")
def mock_db_envs() -> Generator[None, None, None]:
    with mock.patch.dict(os.environ, {}, clear=True):
        yield

test_infinity.py

def test_to_infinity_and_beyond() -> None:
    pass

Results in this log being repeated ad infinitum:

{"cwd": "/app/solomon", "status": "success", "result": {"/app/solomon/tests/test_infinity.py::test_to_infinity_and_beyond": {"test": "/app/solomon/tests/test_infinity.py::test_to_infinity_and_beyond", "outcome": "success", "message": null, "traceback": null, "subtest": null}}, "not_found": null, "error": null}
Plugin error connection error[vscode-pytest]
[vscode-pytest] data: Content-Length: 311
Content-Type: application/json
Request-uuid: unknown
eleanorjboyd commented 1 year ago

Aha! Great catch! Yes, that would be the reason. To confirm you are able to edit the test to still test what you desire for your use case and not edit environment variables right? I am going to go in and add some extra guardrails to help surface this issue to users and stop the infinite return of the payload.

One follow-up, were you seeing the extension crash as a result or would you force crash it to stop it? Wondering if this error led to an overload that caused the extension to crash.

nitsujri commented 1 year ago

Another engineer on our team also ran into this, earlier this morning and adding "python.experiments.optOutFrom": ["pythonTestAdapter"] worked like it did before.

I'm not sure how to help test because we're not directly modifying the os.environ but it's possible I'm doing that accidentally and have no idea. Let me know if I can help test though would be glad to.

jarek-webellian commented 1 year ago

One follow-up, were you seeing the extension crash as a result or would you force crash it to stop it? Wondering if this error led to an overload that caused the extension to crash.

We're running vscode inside a Dev Container on our VM (Ubuntu-based CDE). Once the infinite loop happens, we can either:

As for the previous question - yes, we can remove the fixture modifying os.environ and the problems stop.

underyx commented 1 year ago

I can confirm the fix works on my machine. Thank you!

jarek-webellian commented 1 year ago

Indeed. I can also confirm, that the current pre-release version is working as expected. Thanks! 💯

kwood commented 1 year ago

I am having this issue as well and the pre-release version is an improvement (i.e., my machine no longer screams from the infinite loop) but my tests still aren't discovered. We're not modifying the environment AFAIK, maybe there are other ways to trigger this behavior?


  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 270, in wrap_session
    session.exitstatus = doit(config, session) or 0
                         ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 323, in _main
    config.hook.pytest_collection(session=session)
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^
2023-10-31 20:26:29.729 [error] ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 334, in pytest_collection
    session.perform_collect()

2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 664, in perform_collect

2023-10-31 20:26:29.729 [error]     self.items.extend(self.genitems(node))

2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 831, in genitems

2023-10-31 20:26:29.729 [error]     rep = collect_one_node(node)
          ^^^^^^^^^^
2023-10-31 20:26:29.729 [error] ^^^^^^^^^^^^

2023-10-31 20:26:29.729 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/runner.py", line 538, in collect_one_node

2023-10-31 20:26:29.730 [error]     rep: CollectReport = ihook.pytest_make_collect_report(collector=collector)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)

2023-10-31 20:26:29.730 [error]            ^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec

2023-10-31 20:26:29.730 [error]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)

2023-10-31 20:26:29.730 [error]            ^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.730 [error] ^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 55, in _multicall

2023-10-31 20:26:29.730 [error]     gen.send(outcome)

2023-10-31 20:26:29.730 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 796, in pytest_make_collect_report

2023-10-31 20:26:29.730 [error]     out, err = self.read_global_capture()

2023-10-31 20:26:29.730 [error]      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 718, in read_global_capture
    return self._global_capturing.readouterr()

2023-10-31 20:26:29.730 [error]          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr

2023-10-31 20:26:29.731 [error]     out = self.out.snap() if self.out else ""
          ^^^^^^^^
2023-10-31 20:26:29.731 [error] ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap
    res = self.tmpfile.read()
          ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 290, in wrap_session
    config.notify_exception(excinfo, config.option)
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1094, in notify_exception
    res = self.hook.pytest_internalerror(excrepr=excrepr, excinfo=excinfo)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.731 [error] ^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()

2023-10-31 20:26:29.731 [error]            ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result

2023-10-31 20:26:29.731 [error]     raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall

2023-10-31 20:26:29.731 [error]     res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 826, in pytest_internalerror

2023-10-31 20:26:29.732 [error]     self.stop_global_capturing()
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 693, in stop_global_capturing
    self._global_capturing.pop_outerr_to_orig()

2023-10-31 20:26:29.732 [error]   File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 579, in pop_outerr_to_orig
    out, err = self.readouterr()
               ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr

2023-10-31 20:26:29.732 [error]     out = self.out.snap() if self.out else ""
          ^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap

2023-10-31 20:26:29.732 [error]     res = self.tmpfile.read()
          ^^^^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main

2023-10-31 20:26:29.732 [error]   File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/lib/python3.11/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
                     ^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 190, in console_main

2023-10-31 20:26:29.732 [error]     code = main()
           ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 167, in main

2023-10-31 20:26:29.732 [error]     ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(

2023-10-31 20:26:29.732 [error]                       ^^^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__

2023-10-31 20:26:29.732 [error]     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)

2023-10-31 20:26:29.732 [error]  ^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec

2023-10-31 20:26:29.732 [error]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)

2023-10-31 20:26:29.732 [error]            ^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall

2023-10-31 20:26:29.732 [error]     return outcome.get_result()
           ^^^^^^
2023-10-31 20:26:29.732 [error] ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result

2023-10-31 20:26:29.732 [error]     raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall

2023-10-31 20:26:29.733 [error]     res = hook_impl.function(*args)
          ^^^
2023-10-31 20:26:29.733 [error] ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 317, in pytest_cmdline_main

2023-10-31 20:26:29.733 [error]     return wrap_session(config, _main)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-31 20:26:29.733 [error] ^
  File "/usr/local/lib/python3.11/site-packages/_pytest/main.py", line 312, in wrap_session

2023-10-31 20:26:29.733 [error]     config._ensure_unconfigure()
  File "/usr/local/lib/python3.11/site-packages/_pytest/config/__init__.py", line 1048, in _ensure_unconfigure

2023-10-31 20:26:29.733 [error]     fin()
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 693, in stop_global_capturing

2023-10-31 20:26:29.733 [error]     self._global_capturing.pop_outerr_to_orig()
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 579, in pop_outerr_to_orig

2023-10-31 20:26:29.733 [error]     out, err = self.readouterr()

2023-10-31 20:26:29.733 [error]         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 623, in readouterr

2023-10-31 20:26:29.733 [error]     out = self.out.snap() if self.out else ""
          ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/_pytest/capture.py", line 482, in snap

2023-10-31 20:26:29.733 [error]     res = self.tmpfile.read()

2023-10-31 20:26:29.733 [error] ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory```
eleanorjboyd commented 1 year ago

@kwood, could you send over a minimal repro of your setup? The logs are not giving a ton of insight to help me determine the problem. A minimal repro is just a small example that causes the same bug you see. If I am able to repro it myself that would help me determine the issue- thanks!