-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove autoRestart feature across all SDKs #803
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
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d1d733c
Remove autoRestart feature across all SDKs
SteveSandersonMS c2a79b8
Mark client as disconnected on connection close/error
SteveSandersonMS c2930b4
Fix numbered list after removing auto-restart step
SteveSandersonMS 8f1ae3d
Transition to disconnected state on unexpected process/connection death
SteveSandersonMS 38566a9
Remove .NET disconnection test
SteveSandersonMS e060f62
Re-add autoRestart as deprecated no-op to avoid source-breaking change
SteveSandersonMS c08e283
Fix go fmt alignment in Client struct
SteveSandersonMS 9a571e9
Fix Go onClose deadlock by running state update in goroutine
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
Transition to disconnected state on unexpected process/connection death
All SDKs now properly transition their connection state to 'disconnected' when the child process exits unexpectedly or the TCP connection drops: - Node.js: onClose/onError handlers in attachConnectionHandlers() - Go: onClose callback fired from readLoop() on unexpected exit - Python: on_close callback fired from _read_loop() on unexpected exit - .NET: rpc.Completion continuation sets _disconnected flag Includes unit tests for all four SDKs verifying the state transition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Loading branch information
commit 8f1ae3dcd704dddd4bd8513a355d7a7f02c42bc8
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
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,69 @@ | ||
| package jsonrpc2 | ||
|
|
||
| import ( | ||
| "io" | ||
| "sync" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| func TestOnCloseCalledOnUnexpectedExit(t *testing.T) { | ||
| stdinR, stdinW := io.Pipe() | ||
| stdoutR, stdoutW := io.Pipe() | ||
| defer stdinR.Close() | ||
|
|
||
| client := NewClient(stdinW, stdoutR) | ||
|
|
||
| var called bool | ||
| var mu sync.Mutex | ||
| client.SetOnClose(func() { | ||
| mu.Lock() | ||
| called = true | ||
| mu.Unlock() | ||
| }) | ||
|
|
||
| client.Start() | ||
|
|
||
| // Simulate unexpected process death by closing the stdout writer | ||
| stdoutW.Close() | ||
|
|
||
| // Wait for readLoop to detect the close and invoke the callback | ||
| time.Sleep(200 * time.Millisecond) | ||
|
|
||
| mu.Lock() | ||
| defer mu.Unlock() | ||
| if !called { | ||
| t.Error("expected onClose to be called when read loop exits unexpectedly") | ||
| } | ||
| } | ||
|
|
||
| func TestOnCloseNotCalledOnIntentionalStop(t *testing.T) { | ||
| stdinR, stdinW := io.Pipe() | ||
| stdoutR, stdoutW := io.Pipe() | ||
| defer stdinR.Close() | ||
| defer stdoutW.Close() | ||
|
|
||
| client := NewClient(stdinW, stdoutR) | ||
|
|
||
| var called bool | ||
| var mu sync.Mutex | ||
| client.SetOnClose(func() { | ||
| mu.Lock() | ||
| called = true | ||
| mu.Unlock() | ||
| }) | ||
|
|
||
| client.Start() | ||
|
|
||
| // Intentional stop — should set running=false before closing stdout, | ||
| // so the readLoop should NOT invoke onClose. | ||
| client.Stop() | ||
|
|
||
| time.Sleep(200 * time.Millisecond) | ||
|
|
||
| mu.Lock() | ||
| defer mu.Unlock() | ||
| if called { | ||
| t.Error("onClose should not be called on intentional Stop()") | ||
| } | ||
| } |
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
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.