microsoft / microsoft/vscode-python-debugger
Race condition in `provider.unit.test.ts` due to slow initial execution
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 181
- Fork
- 126
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 3
Mô tả
📝 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:
- 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.
- Polluted Assertions: While the second test is running, the asynchronous call from the first (timed-out) test finally completes.
- Double Call Error: This causes the
sinonstub (likeplainExec) 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
- Run tests in a resource-constrained environment (like a cold GitHub Actions runner or a slow local machine).
- Execute npm run test (or the equivalent test runner command).
- 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.
- 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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với provider.unit.test.ts và suite AttachProcessProvider, sau đó chạy npm run test trong môi trường chậm hoặc lạnh để tái hiện timeout và lỗi stub tiếp theo. Hoàn tất khi test đầu tiên hoàn thành ổn định trong suite và các assertion cho Linux và macOS đều đạt mà không có lời gọi nào bị rò rỉ giữa các test.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- testing
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 58/100