-
Notifications
You must be signed in to change notification settings - Fork 2.3k
refactor(coding-agent): await the spawn event instead of a startup sleep #1854
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
Open
snimu
wants to merge
13
commits into
main
Choose a base branch
from
snimu/rpc-start-readiness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4130037
fix(coding-agent): remove blanket RPC timeouts, reject on real bounda…
snimu c33e516
refactor(coding-agent): await the spawn event instead of a startup sleep
snimu 8d416f4
fix(coding-agent): make RpcClient.stop() exit-based so held stdio pip…
snimu a2aa629
Merge branch 'solo/B2' into solo/C8
snimu 7a05456
fix(coding-agent): scope RPC child lifecycle handlers to the active c…
snimu f1654c3
Merge branch 'solo/B2' into solo/C8
snimu 887f0de
fix(coding-agent): clear this.process when the spawn await rejects so…
snimu f45c058
fix(coding-agent): drain buffered stdout before failing pending ops o…
snimu 9f270da
Merge branch 'solo/B2' into solo/C8
snimu f1a560e
fix(coding-agent): cut the previous child generation on RPC client re…
snimu 8c392f1
Merge branch 'solo/B2' into solo/C8
snimu 6bf726d
test(coding-agent): prove ghost-event delivery via a stderr sentinel
snimu 2cccab2
Merge branch 'solo/B2' into solo/C8
snimu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Allowed long-running RPC commands and agent turns to complete without fixed client timeouts. |
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 @@ | ||
| - Removed the fixed delay when starting an RPC client. |
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
30 changes: 30 additions & 0 deletions
30
packages/coding-agent/test/fixtures/rpc-client-hanging-fixture.mjs
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,30 @@ | ||
| import { spawn } from "node:child_process"; | ||
|
|
||
| if (process.env.RPC_FIXTURE_HOLD_STDIO === "1") { | ||
| // A grandchild inheriting the stdio pipes keeps them open after this process exits, | ||
| // so the parent RpcClient never sees a "close" event for this child. | ||
| // The ghost variant writes an event into the inherited stdout shortly after this | ||
| // process dies, emulating child output that lands after a replacement started. | ||
| const script = | ||
| process.env.RPC_FIXTURE_GHOST_EVENT === "1" | ||
| ? `process.stdin.on("end", () => setTimeout(() => { process.stdout.write('{"type":"agent_end"}\\n'); process.stderr.write("ghost-event-written\\n"); }, 250)); process.stdin.resume(); setTimeout(() => {}, 30000);` | ||
| : "setTimeout(() => {}, 30000)"; | ||
|
snimu marked this conversation as resolved.
|
||
| const grandchild = spawn(process.execPath, ["-e", script], { | ||
| stdio: "inherit", | ||
| detached: true, | ||
| }); | ||
| grandchild.unref(); | ||
| process.stdout.write(`${JSON.stringify({ type: "fixture_grandchild", pid: grandchild.pid })}\n`); | ||
| } | ||
|
|
||
| if (process.env.RPC_FIXTURE_REPLY_EXIT === "1") { | ||
| // Answer the first command, then die immediately: the response is still in the | ||
| // pipe (or draining) when "exit" reaches the parent. | ||
| process.stdin.once("data", (chunk) => { | ||
| const { id, type } = JSON.parse(chunk.toString()); | ||
| process.stdout.write(`${JSON.stringify({ id, type: "response", command: type, success: true, data: {} })}\n`); | ||
| process.exit(0); | ||
| }); | ||
| } | ||
|
|
||
| process.stdin.resume(); | ||
Oops, something went wrong.
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.