microsoft / microsoft/vscode-python-debugger

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

Aberta
#1,031 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

triage-needed
Linguagem predominante
TypeScript
Estrelas
181
Forks
126
Merge médio
2d 3h
PRs com merge (30d)
3

Descrição

📝 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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com provider.unit.test.ts e a suite AttachProcessProvider; em seguida, execute npm run test em um ambiente lento ou frio para reproduzir o timeout e a falha subsequente do stub. Considera-se concluído quando o primeiro teste for concluído de forma confiável dentro da suite e as asserções de Linux e macOS passarem sem que chamadas vazem entre os testes.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
typescript
Domínio
testing
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
58/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.