microsoft / microsoft/vscode-python-debugger

Race condition in `provider.unit.test.ts` due to slow initial execution

Offen
#1,031 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

triage-needed
Vorherrschende Sprache
TypeScript
Sterne
181
Forks
126
Ø Merge
2 T. 3 Std.
Gemergte PRs (30 T.)
3

Beschreibung

📝 Description

We are observing intermittent test failures during the first run of the unit tests, specifically within the AttachProcessProvider suite.

The root cause appears to be a Race Condition triggered by slow environment startup:

  1. First Test Timeout: The first test case (e.g., Linux process list) takes longer than 2000ms to resolve (likely due to initial module loading or environment lag), causing a Mocha timeout error.
  2. Polluted Assertions: While the second test is running, the asynchronous call from the first (timed-out) test finally completes.
  3. Double Call Error: This causes the sinon stub (like plainExec) to record an extra call during the second test's execution context, leading to an assertion failure: expected plainExec to be called once but it was called twice (or similar).
  586 passing (6s)
  27 pending
  2 failing
  1) Attach to process - process provider
       The Linux process list command should be called if the platform is Linux:
     Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/home/runner/work/vscode-python-debugger/vscode-python-debugger/testDir/out/test/unittest/attachQuickPick/provider.unit.test.js)
  	at listOnTimeout (node:internal/timers:585:17)
  	at process.processTimers (node:internal/timers:521:7)

  2) Attach to process - process provider
       The macOS process list command should be called if the platform is macOS:
     AssertError: expected plainExec to be called once and with exact arguments 
🛠 Steps to Reproduce
  1. Run tests in a resource-constrained environment (like a cold GitHub Actions runner or a slow local machine).
  2. Execute npm run test (or the equivalent test runner command).
  3. Observe that the first test fails with a timeout, and subsequent tests fail because stubs were called by the "ghost" of the previous failed test.
  4. Run the tests again immediately; observe that all tests (including the previously failed ones) now pass.

Environment: CI (GitHub Runner) https://github.com/ZA139/vscode-python-debugger/actions/runs/25676102630/job/75374288168 / Local Windows

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit provider.unit.test.ts und der AttachProcessProvider-Testsuite. Führe anschließend npm run test in einer langsamen oder kalten Umgebung aus, um das Timeout und den anschließenden Stub-Fehler zu reproduzieren. Fertig ist die Aufgabe, wenn der erste Test innerhalb der Suite zuverlässig abgeschlossen wird und die Assertions für Linux und macOS bestehen, ohne dass Aufrufe zwischen Tests durchsickern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
testing
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.