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

Daemonize addon store, timeout web requests #16183

Merged
merged 9 commits into from
Feb 19, 2024
Merged

Daemonize addon store, timeout web requests #16183

merged 9 commits into from
Feb 19, 2024

Conversation

seanbudd
Copy link
Member

@seanbudd seanbudd commented Feb 16, 2024

Link to issue number:

May fix most cases of #16123 and #16122

Summary of the issue:

requests.get has no default timeout, meaning a connection may hang until it is closed by the server.
The add-on store uses requests with no timeout to fetch data from the add-on store, and download add-ons.
This can cause threads to hang, preventing NVDA from exiting correctly.

Update check also has similar risks with usage of urllib like requests.

Many threads started in NVDA should also be daemonized.

Description of user facing changes

NVDA should exit properly in more cases, make installs safer

Description of development approach

Add timeouts for web requests and daemonize all threads in NVDA.

Testing strategy:

Smoke tested running the installer and using the add-on store

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@seanbudd seanbudd requested a review from a team as a code owner February 16, 2024 01:15
@seanbudd seanbudd requested review from michaelDCurran and removed request for a team February 16, 2024 01:15
@seanbudd seanbudd changed the title Daemonize addon store Daemonize addon store, timeout web requests Feb 16, 2024

def terminate(self):
if self._getAddonsThread.is_alive():
self._getAddonsThread.join(timeout=FETCH_TIMEOUT_S + 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having NvDA hang on exit for up to 120 seconds does not sound that great.
In deed, restarting NVDA, the new NvDA would kill it off after 10 seconds anyway.
What would be the consequence of not joining the thread here, and just having it killed off (as it is now a daemon thread) on process exit?
If it is important that we have the ability to clean up after requests/get etc returns on terminate, then we could look at putting every requests.get call in its own daemon thread which we would normally block on, but would have the ability to abandon if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this timeout to 1. It's probably fine not to join, but if we reset config and reinitialize submodules the thread should be killed before firing the next one on initialization.

@AppVeyorBot
Copy link

See test results for failed build of commit 2d8d7f1a32

source/_addonStore/dataManager.py Show resolved Hide resolved
source/_addonStore/dataManager.py Show resolved Hide resolved
source/_addonStore/dataManager.py Outdated Show resolved Hide resolved
source/remotePythonConsole.py Outdated Show resolved Hide resolved
@seanbudd seanbudd added this to the 2023.3.4 milestone Feb 19, 2024
source/watchdog.py Outdated Show resolved Hide resolved
michaelDCurran
michaelDCurran previously approved these changes Feb 19, 2024
@seanbudd seanbudd merged commit b9d1535 into rc Feb 19, 2024
1 of 2 checks passed
@seanbudd seanbudd deleted the daemonizeAddonStore branch February 19, 2024 02:28
Adriani90 pushed a commit to Adriani90/nvda that referenced this pull request Mar 13, 2024
May fix most cases of nvaccess#16123 and nvaccess#16122

Summary of the issue:
requests.get has no default timeout, meaning a connection may hang until it is closed by the server.
The add-on store uses requests with no timeout to fetch data from the add-on store, and download add-ons.
This can cause threads to hang, preventing NVDA from exiting correctly.

Update check also has similar risks with usage of urllib like requests.

Many threads started in NVDA should also be daemonized.

Description of user facing changes
NVDA should exit properly in more cases, make installs safer

Description of development approach
Add timeouts for web requests and daemonize all threads in NVDA.
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

Successfully merging this pull request may close these issues.

4 participants