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

未關閉
#1,031 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
58/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
typescript
領域
testing

研究方向

從 provider.unit.test.ts 和 AttachProcessProvider suite 開始,然後在緩慢或冷啟動的環境中執行 npm run test,以重現逾時和後續的 stub 失敗。完成的標準是 suite 中的第一個測試能可靠地完成,且 Linux 和 macOS 的斷言通過,同時呼叫不會在測試之間洩漏。

由索引模型根據 Issue 內容生成。

描述

triage-needed
📝 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

主要語言
TypeScript
星號
181
分支
126
平均合併
2 天 3 小時
30 天內合併 PR
3

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/vscode-python-debugger 的其他 Issue

查看 microsoft/vscode-python-debugger 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。