Repository navigation
fix: queue ACP requests until startup completes - #4541
Conversation
🦋 Changeset detectedLatest commit: 425121e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48d3bcc6ba
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let resolveServer!: (server: AcpServer) => void; | ||
| const serverReady = new Promise<AcpServer>((resolve) => { | ||
| resolveServer = resolve; | ||
| }); | ||
| const app = createAcpAgentApp(() => serverReady); |
There was a problem hiding this comment.
Reject queued requests when startup fails
When addProvider rejects—for example, because IHostEnvironment.ready rejects after the connection accepts an early request—runAcpServerWithStream rejects, but this resolve-only promise never settles. The new request handlers therefore remain pending indefinitely, and embedders cannot close the connection because no RunningAcpServer was returned; give serverReady a rejection path and settle or close it on startup failure.
AGENTS.md reference: AGENTS.md:L123-L125
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
commit: |
Requirement or Bug
Zed 等 ACP 客户端会在连接建立后立即发送
initialize,remote environments 扩大启动窗口后,这条请求可能收到Internal error,导致会话无法开始。本 PR 之后,客户端可以正常完成启动握手;如果服务启动失败,也会收到包含真实原因的错误。Bug Reproduction Steps
kimi acp。initialize请求,无需等待服务启动完成。-32603 Internal error,错误详情为Cannot read properties of undefined (reading 'initialize')。Root Cause
app.connect(stream)在server赋值前开始读取请求。addProvider()等待localReady期间,提前到达的initialize会通过getServer()解引用仍为undefined的server。这是根本修复:连接与请求分发之间增加明确的就绪边界。所有处理器等待
serverReady;启动成功时 resolve,provider 注册失败时 reject,因此排队请求不会提前执行或无限等待。Code Changes
createAcpAgentApp同时接受同步或异步getServer,保留已有同步调用方的类型兼容。serverReady预置空 catch,避免没有早期请求时产生未处理 rejection;原始启动异常仍由runAcpServerWithStream原样抛出。Behavior Changes and Affected Users
initialize可能因server未赋值返回-32603server未赋值的错误,掩盖真实启动原因-32603,请求不会悬挂启动成功、启动窗口内握手、provider 注册失败和既有会话流程均有回归覆盖。ACP 方法、能力矩阵、配置、环境变量及持久化数据格式未改变;prompt 与 KAP 路径不受影响。
验证记录
packages/acp-server/test/initialize.test.ts新增两条用例:启动完成前发送initialize,以及 provider 注册失败时拒绝已排队请求。server未赋值错误;第二条在缺少 rejection 路径时稳定超时。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.