Skip to content

Fix SSL state pollution causing self-test failures on Windows (Python 3.13+)#308

Open
begna112 wants to merge 1 commit intovast-ai:masterfrom
begna112:fix/self-test-ssl-state-pollution
Open

Fix SSL state pollution causing self-test failures on Windows (Python 3.13+)#308
begna112 wants to merge 1 commit intovast-ai:masterfrom
begna112:fix/self-test-ssl-state-pollution

Conversation

@begna112
Copy link

@begna112 begna112 commented Jan 11, 2026

Summary

  • Fixes self-test machine command failing with FileNotFoundError on Windows with Python 3.13+
  • Uses a custom HTTPAdapter with a fresh SSL context to isolate progress endpoint requests
  • Might be the cause of many new hosts having issues running self-tests if they are freshly installing the latest versions of Python on Windows.

Problem

The self-test machine command was failing with a cryptic error when polling the /progress endpoint:

FileNotFoundError: [Errno 2] No such file or directory

The full traceback showed the error originating from Python's SSL layer during socket reads:

File "ssl.py", line 1138, in read
    return self._sslobj.read(len, buffer)
FileNotFoundError: [Errno 2] No such file or directory

Strangely, the same HTTPS request to the same URL worked fine when executed in a fresh Python process, but failed when run within the vast.py script.

Root Cause

SSL context state pollution from earlier API requests to console.vast.ai (during instance creation and status polling) was corrupting the default connection pool used by the requests library. When run_machinetester later tried to poll the test instance's /progress endpoint, the corrupted SSL state caused the FileNotFoundError.

Solution

Use a custom HTTPAdapter that creates a fresh SSL context for each polling session. This isolates the progress endpoint requests from any state accumulated during earlier API calls:

class FreshSSLAdapter(HTTPAdapter):
    def init_poolmanager(self, *args, **kwargs):
        ctx = create_urllib3_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        kwargs['ssl_context'] = ctx
        return super().init_poolmanager(*args, **kwargs)

Testing

Tested on Windows 11:

  • Python 3.12: Bug does NOT occur (works without fix)
  • Python 3.13: Bug occurs (fixed by this PR)
  • Python 3.14: Bug occurs (fixed by this PR)
  • Ubuntu 25.04: Bug does NOT occur (works without fix)

This suggests the issue is related to SSL handling changes introduced in Python 3.13 on Windows.

Test plan

  • Run vastai self-test machine <machine_id> on Windows with Python 3.13+
  • Verify test completes without SSL errors
  • Confirm no regression on Python 3.12 or Linux
  • Confirm if this also needs to be addressed in the python SDK.

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.

1 participant