Title: Test Explorer always waits an extra ~5s per run: named-pipe "drain" deferred never resolves, falls back to RESULT_PIPE_DRAIN_TIMEOUT_MS · Issue #26071 · microsoft/vscode-python · GitHub
Open Graph Title: Test Explorer always waits an extra ~5s per run: named-pipe "drain" deferred never resolves, falls back to RESULT_PIPE_DRAIN_TIMEOUT_MS · Issue #26071 · microsoft/vscode-python
X Title: Test Explorer always waits an extra ~5s per run: named-pipe "drain" deferred never resolves, falls back to RESULT_PIPE_DRAIN_TIMEOUT_MS · Issue #26071 · microsoft/vscode-python
Description: Type: Performance Issue Behaviour I asked Claude (Anthropic's Claude Code) to investigate this and put together a minimal repro. The rest of this section is its summary. Every test run started from the Test Explorer / gutter "run" button...
Open Graph Description: Type: Performance Issue Behaviour I asked Claude (Anthropic's Claude Code) to investigate this and put together a minimal repro. The rest of this section is its summary. Every test run started from...
X Description: Type: Performance Issue Behaviour I asked Claude (Anthropic's Claude Code) to investigate this and put together a minimal repro. The rest of this section is its summary. Every test run started ...
Opengraph URL: https://github.com/microsoft/vscode-python/issues/26071
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Test Explorer always waits an extra ~5s per run: named-pipe \"drain\" deferred never resolves, falls back to RESULT_PIPE_DRAIN_TIMEOUT_MS","articleBody":"\nType: \u003cb>Performance Issue\u003c/b>\n\n\u003c!-- Please fill in all XXX markers -->\n# Behaviour\n\n> I asked Claude (Anthropic's Claude Code) to investigate this and put together a minimal repro. The rest of this section is its summary.\n\nEvery test run started from the Test Explorer / gutter \"run\" button takes about 5 seconds longer than the pytest subprocess itself needs. The Testing view's spinner keeps spinning for that extra ~5s after the actual test run has already finished, before the run can be started again.\n\nWith the Python extension's log level set to `Trace`, the `Python` output channel shows the same pattern on every single run (not intermittently):\n\n```\n15:35:34.037 [debug] Test run finished, subprocess closed.\n15:35:39.039 [debug] awaitDeferredWithTimeout: deferred did not settle within 5000ms; giving up and continuing.\n15:35:39.040 [debug] Finished running tests, ending runInstance.\n```\n\nThe pytest subprocess exits at `.037`, and exactly 5000ms later (`.039`) `awaitDeferredWithTimeout` gives up and the run is finally marked finished. This 5000ms gap is identical on every run.\n\nLooking at the bundled extension source (`out/client/extension.js`), the pytest execution adapter always does, in a `finally` block after the run:\n\n```js\nfinally { await awaitDeferredWithTimeout(deferred, RESULT_PIPE_DRAIN_TIMEOUT_MS) }\n```\n\nwhere `RESULT_PIPE_DRAIN_TIMEOUT_MS = 5000` is hardcoded (no user-facing setting), and:\n\n```js\nt.awaitDeferredWithTimeout = async function (e, t) {\n let n;\n try {\n await Promise.race([\n e.promise,\n new Promise((e) => {\n n = setTimeout(() => {\n traceVerbose(`awaitDeferredWithTimeout: deferred did not settle within ${t}ms; giving up and continuing.`);\n e();\n }, t);\n }),\n ]);\n } finally {\n n && clearTimeout(n);\n }\n};\n```\n\nThe `deferred` is only resolved from inside the results named-pipe wrapper's own `dispose()` callback (`startRunResultNamedPipe`, same file), which is expected to fire when the pipe reports a clean end-of-stream/drain. In this environment that resolution never arrives before the 5s timeout, so every run falls through to the \"give up and continue\" branch and eats the full 5 seconds on top of the real test time.\n\nOn the Python side (`python_files/vscode_pytest/__init__.py`), the writer end of the results pipe is only closed via:\n\n```python\natexit.register(lambda: __writer.close() if __writer else None)\n```\n\ni.e. it relies on full interpreter shutdown to close the pipe, rather than closing/flushing the connection proactively right after the last result is written. This looks like the likely reason the \"drain\" signal the extension is waiting on doesn't arrive in time, making the 5s timeout the common case rather than a rare fallback.\n\nFor a fast test suite (a few seconds or less), this hardcoded wait dominates the total run time and makes iterating on individual tests via the Test Explorer noticeably slower than running `pytest` directly from a terminal.\n\n## Steps to reproduce:\n\n1. Open a workspace with `python.testing.pytestEnabled: true` and at least one pytest test.\n2. Set the Python extension log level to `Trace` (Command Palette → `Developer: Set Log Level...` → `Python`).\n3. Run any test from the Testing view or the gutter icon.\n4. Watch the Testing view spinner and the `Python` output channel: the spinner keeps spinning for ~5s after \"Test run finished, subprocess closed.\" is logged, until `awaitDeferredWithTimeout` gives up.\n\n\u003c!--\n**After** creating the issue on GitHub, you can add screenshots and GIFs of what is happening. Consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ for GIF creation.\n-->\n\n\u003c!-- **NOTE**: Please do provide logs from Python Output panel. -->\n# Diagnostic data\n\n\u003cdetails>\n\n\u003csummary>Output for \u003ccode>Python\u003c/code> in the \u003ccode>Output\u003c/code> panel (\u003ccode>View\u003c/code>→\u003ccode>Output\u003c/code>, change the drop-down the upper-right of the \u003ccode>Output\u003c/code> panel to \u003ccode>Python\u003c/code>)\n\u003c/summary>\n\n\u003cp>\n\n```\n2026-07-28 15:35:31.813 [debug] Starting Test Result named pipe\n2026-07-28 15:35:31.813 [debug] Test Results named pipe /run/user/1001/python-test-results-a573e256a741ea7b46bd connected\n2026-07-28 15:35:31.814 [debug] Executable path for pytest execution: /path/to/workspace/.venv/bin/python.\n2026-07-28 15:35:31.814 [info] arg: --rootdir already exists in args, not adding.\n2026-07-28 15:35:31.814 [info] Attempting to use temp directory for test ids file, file name: test-ids-1acf8ccdcb1412644b52.txt\n2026-07-28 15:35:31.828 [info] Environment variables set for pytest execution: PYTHONPATH=/path/to/.vscode/extensions/ms-python.python-2026.5.2026070801-linux-x64/python_files:./, TEST_RUN_PIPE=/run/user/1001/python-test-results-a573e256a741ea7b46bd, RUN_TEST_IDS_PIPE=/run/user/1001/test-ids-1acf8ccdcb1412644b52.txt\n2026-07-28 15:35:31.829 [info] Running pytest with arguments: /path/to/.vscode/extensions/ms-python.python-2026.5.2026070801-linux-x64/python_files/vscode_pytest/run_pytest_script.py --rootdir=/path/to/workspace for workspace /path/to/workspace\n2026-07-28 15:35:31.829 [info] > ./.venv/bin/python ~/.vscode/extensions/ms-python.python-2026.5.2026070801-linux-x64/python_files/vscode_pytest/run_pytest_script.py --rootdir=.\n2026-07-28 15:35:31.829 [info] cwd: .\n2026-07-28 15:35:33.544 [debug] Test Result named pipe /run/user/1001/python-test-results-a573e256a741ea7b46bd received data\n2026-07-28 15:35:34.037 [debug] Test run finished, subprocess closed.\n2026-07-28 15:35:39.039 [debug] awaitDeferredWithTimeout: deferred did not settle within 5000ms; giving up and continuing.\n2026-07-28 15:35:39.040 [debug] Finished running tests, ending runInstance.\n```\n\n\u003c/p>\n\u003c/details>\n\n**Environment**\n\n- VS Code Version: 1.130.0\n- Python Extension Version: 2026.5.2026070801\n- OS Version: Debian GNU/Linux 13 (trixie), kernel 6.12.96+deb13-amd64, x86_64\n- Python interpreter: 3.14.6 (CPython, uv-managed virtualenv, `.venv`)\n- Test framework: pytest 9.1.1\n\n\nExtension version: 2026.5.2026070801\nVS Code version: Code 1.130.0 (1b6a188127eeaf9194f945eb6eb89a657e93c54c, 2026-07-22T14:55:04Z)\nOS version: Linux x64 6.12.96+deb13-amd64\nModes:\n\n- Python version (& distribution if applicable, e.g. Anaconda): 3.14.6\n- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv\n- Value of the `python.languageServer` setting: None\n\n\u003cdetails>\n\u003csummary>User Settings\u003c/summary>\n\u003cp>\n\n```\n\nlanguageServer: \"None\"\n\ntesting\n• pytestArgs: \"\u003cplaceholder>\"\n• pytestEnabled: true\n\n```\n\u003c/p>\n\u003c/details>\n\n\u003cdetails>\n\u003csummary>Installed Extensions\u003c/summary>\n\n|Extension Name|Extension Id|Version|\n|---|---|---|\n|copilot-chat|Git|0.58.0|\n|debugpy|ms-|2026.7.12081008|\n|docker|doc|0.18.0|\n|js-debug|ms-|1.117.0|\n|js-debug-companion|ms-|1.1.3|\n|jsts-chat-features|Typ|0.0.4|\n|jupyter|ms-|2026.6.2026071501|\n|jupyter-keymap|ms-|1.1.2|\n|jupyter-renderers|ms-|1.3.2025062701|\n|python|ms-|2026.5.2026070801|\n|ruff|cha|2026.66.0|\n|ty|ast|2026.64.0|\n|vscode-containers|ms-|2.4.5|\n|vscode-cython|ktn|1.0.3|\n|vscode-js-profile-table|ms-|1.0.10|\n|vscode-python-envs|ms-|1.37.2026072401|\n\u003c/details>\n\u003cdetails>\n\u003csummary>System Info\u003c/summary>\n\n|Item|Value|\n|---|---|\n|CPUs|Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz (8 x 3399)|\n|GPU Status|2d_canvas: enabled\u003cbr>GPU0: VENDOR= 0x8086 [Google Inc. (Intel)], DEVICE=0x9b41 [ANGLE (Intel, Mesa Intel(R) UHD Graphics (CML GT2), OpenGL ES 3.2 Mesa 25.0.7-2+deb13u1)], DRIVER_VENDOR=Mesa, DRIVER_VERSION=25.0.7 *ACTIVE*\u003cbr>Machine model name: \u003cbr>Machine model version: \u003cbr>direct_rendering_display_compositor: disabled_off_ok\u003cbr>gpu_compositing: enabled\u003cbr>multiple_raster_threads: enabled_on\u003cbr>opengl: enabled_on\u003cbr>rasterization: enabled\u003cbr>raw_draw: disabled_off_ok\u003cbr>skia_graphite: disabled_off\u003cbr>trees_in_viz: disabled_off\u003cbr>video_decode: enabled\u003cbr>video_encode: disabled_software\u003cbr>vulkan: disabled_off\u003cbr>webgl: enabled\u003cbr>webgpu: enabled\u003cbr>webgpu_on_vk_via_gl_interop: disabled_off\u003cbr>webnn: disabled_off|\n|Load (avg)|0, 0, 0|\n|Memory (System)|15.32GB (11.51GB free)|\n|Process Argv|.|\n|Screen Reader|no|\n|VM|0%|\n|DESKTOP_SESSION|gnome|\n|XDG_CURRENT_DESKTOP|GNOME|\n|XDG_SESSION_DESKTOP|gnome|\n|XDG_SESSION_TYPE|wayland|\n\u003c/details>\n\u003c!-- generated by issue reporter -->","author":{"url":"https://github.com/alihamdan","@type":"Person","name":"alihamdan"},"datePublished":"2026-07-28T14:07:53Z","url":"https://github.com/microsoft/vscode-python/issues/26071"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c7fcb187-d4aa-cc8d-8281-cbc9c567aeca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C70A:21BD98:C33AB:F530B:6B00F6A3 |
| html-safe-nonce | ff953b794f5be4a01908113611dd4b3d621ab46b327f665921b81f9a747868fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzBBOjIxQkQ5ODpDMzNBQjpGNTMwQjo2QjAwRjZBMyIsInZpc2l0b3JfaWQiOiI1NDk1OTI0MDY0NTMyODg3MjA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4994c8b43aaf92b4a6fc24a451b2b272333e081183628361e5a759343c5c4b42 |
| hovercard-subject-tag | issue:4999478092 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/vscode-python/26071/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4647f2cdb9cd93ea3fd70483ac93e0d0b72110f054819f8e67ba5a356a75d0ab/microsoft/vscode-python/issues/26071 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4647f2cdb9cd93ea3fd70483ac93e0d0b72110f054819f8e67ba5a356a75d0ab/microsoft/vscode-python/issues/26071 |
| og:image:alt | Type: Performance Issue Behaviour I asked Claude (Anthropic's Claude Code) to investigate this and put together a minimal repro. The rest of this section is its summary. Every test run started from... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alihamdan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/vscode-python git https://github.com/microsoft/vscode-python.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 106462765 |
| octolytics-dimension-repository_nwo | microsoft/vscode-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 49946255 |
| octolytics-dimension-repository_parent_nwo | DonJayamanne/pythonVSCode |
| octolytics-dimension-repository_network_root_id | 49946255 |
| octolytics-dimension-repository_network_root_nwo | DonJayamanne/pythonVSCode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width