Repository navigation
fix(python,nodejs): serialize concurrent client startup #2570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
SteveSandersonMS
merged 4 commits into
github:main
from
xianjianlf2:fix/python-concurrent-start
Sep 10, 2026
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3cebaea
fix(python): serialize concurrent client startup
xianjianlf2 91b5abc
fix(nodejs): serialize concurrent client startup
SteveSandersonMS cbde8b0
fix(python): discard unused await result flagged by CodeQL
SteveSandersonMS 5a36b22
fix(nodejs): pin explicit gitHubToken in cold-resume e2e test
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """Startup concurrency regressions without a live CLI runtime.""" | ||
|
|
||
| import asyncio | ||
| from unittest.mock import AsyncMock | ||
|
|
||
| import pytest | ||
|
|
||
| from copilot import CopilotClient, RuntimeConnection | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def client(): | ||
| client = CopilotClient(connection=RuntimeConnection.for_stdio(path="unused-cli")) | ||
| client._start_cli_server = AsyncMock() | ||
| client._connect_to_server = AsyncMock() | ||
| client._verify_protocol_version = AsyncMock() | ||
| return client | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "phase", ["_start_cli_server", "_connect_to_server", "_verify_protocol_version"] | ||
| ) | ||
| async def test_concurrent_start_initializes_transport_once(client, phase): | ||
| entered = asyncio.Event() | ||
| release = asyncio.Event() | ||
|
|
||
| async def block(): | ||
| entered.set() | ||
| await release.wait() | ||
|
|
||
| getattr(client, phase).side_effect = block | ||
| first = asyncio.create_task(client.start()) | ||
| await asyncio.wait_for(entered.wait(), timeout=1) | ||
| second = asyncio.create_task(client.start()) | ||
| try: | ||
| await asyncio.sleep(0) | ||
| assert not second.done() | ||
| finally: | ||
| release.set() | ||
| await asyncio.wait_for(asyncio.gather(first, second), timeout=1) | ||
|
|
||
| client._start_cli_server.assert_awaited_once() | ||
| client._connect_to_server.assert_awaited_once() | ||
| client._verify_protocol_version.assert_awaited_once() | ||
| await client.start() | ||
| client._start_cli_server.assert_awaited_once() | ||
|
|
||
|
|
||
| async def test_start_can_retry_after_failure(client): | ||
| client._start_cli_server.side_effect = [RuntimeError("startup failed"), None] | ||
|
|
||
| with pytest.raises(RuntimeError, match="startup failed"): | ||
| await client.start() | ||
| await asyncio.wait_for(client.start(), timeout=1) | ||
|
|
||
| assert client._start_cli_server.await_count == 2 | ||
| client._connect_to_server.assert_awaited_once() | ||
| client._verify_protocol_version.assert_awaited_once() | ||
|
|
||
|
|
||
| async def test_cancelling_waiting_start_does_not_cancel_active_start(client): | ||
| entered = asyncio.Event() | ||
| release = asyncio.Event() | ||
|
|
||
| async def block(): | ||
| entered.set() | ||
| await release.wait() | ||
|
|
||
| client._start_cli_server.side_effect = block | ||
| first = asyncio.create_task(client.start()) | ||
| await asyncio.wait_for(entered.wait(), timeout=1) | ||
| second = asyncio.create_task(client.start()) | ||
| try: | ||
| await asyncio.sleep(0) | ||
| second.cancel() | ||
| with pytest.raises(asyncio.CancelledError): | ||
| await second | ||
| assert not first.done() | ||
| finally: | ||
| release.set() | ||
| await asyncio.wait_for(first, timeout=1) | ||
|
|
||
| await client.start() | ||
| client._start_cli_server.assert_awaited_once() | ||
| client._verify_protocol_version.assert_awaited_once() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.