Repository navigation
fix(cli): share telemetry shutdown deadline - #2333
ousamabenyounes wants to merge 6 commits into
Conversation
🦋 Changeset detectedLatest commit: 94cc62f 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 |
1b99613 to
c4d9e1a
Compare
c4d9e1a to
ccc6976
Compare
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: 1604d213b9
ℹ️ 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".
1604d21 to
01e851e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01e851e8a1
ℹ️ 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".
01e851e to
1b00403
Compare
|
Rebased onto current main, resolved the conflicts, restored the separate server-close error boundary, and rewrote the changeset around the observable shutdown-delay fix. The focused web suite passes 68/68, and full local CI is iso-or-better with 100% changed-line coverage. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b00403e55
ℹ️ 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".
A stalled token lookup can ignore the transport abort signal. Bound the await so later cleanup runs and startup errors surface.
67b4479 to
94cc62f
Compare
|
Rebased this PR onto current Addressed the two open review threads: startup-failure cleanup uses the shared deadline (existing follow-up Validation on the rebased head: stalled-host-lookup regression RED before / GREEN after the new bound, 128/128 focused tests, both affected package typechecks, CLI production build, and lint for modified files pass. GitHub currently shows no status checks for this fork PR, so the remote CI result is not yet independently available; the remaining |
Requirement or Bug
Resolve #2248. CLI shutdown previously gave each telemetry owner a separate timeout, so a stalled engine pipeline followed by a stalled host pipeline could delay exit beyond the configured budget. The same budget must also cover cleanup after web startup fails.
Bug Reproduction Steps
The regression tests run two stalled telemetry pipelines under fake time. Before this change, their cumulative shutdown time exceeded one budget; the startup-failure cleanup path had the same problem. See
apps/kimi-code/test/cli/telemetry.test.ts,apps/kimi-code/test/cli/web/web.test.ts, andpackages/kap-server/test/boot.test.ts.Root Cause
The print and web entrypoints passed a fresh timeout to each independently owned telemetry pipeline.
RunningServer.close()had no way to receive the absolute deadline from the web host, and the webonReadyrejection path bypassed the normal shutdown policy. This is a shared-deadline fix, not a change to telemetry transport or stored data.Code Changes
One absolute deadline is created at each CLI shutdown boundary. Each pipeline receives only the remaining time, and the caller also bounds the await so a stalled token lookup cannot outlive the deadline. A rejection or timeout is reported without blocking the next owner. Web startup failure now uses the same close helper as normal shutdown.
The server-close error boundary remains distinct from telemetry failures, and print exit results are preserved. Start with
apps/kimi-code/src/cli/telemetry-shutdown.ts, then the print/web call sites andpackages/kap-server/src/start.ts.Behavior Changes and Affected Users
kimi webexit or startup failureonReadyfailedPrevious-release clients and data remain compatible: this PR changes shutdown timing and warning behavior only. Existing CLI arguments, printed result formats, exit outcomes, REST/WebSocket contracts, remote-control messages, and stored sessions remain readable and unchanged. A stalled telemetry owner may receive less time than before because it shares the process exit budget; the configured budget itself and the telemetry setting stay the same.
Affected modules and evidence: print lifecycle tests cover failure, reporter failure, expired budget, and preserved exit result; web lifecycle tests cover normal shutdown, startup failure, and server-close error; kap-server tests cover the propagated deadline. On the rebased branch, 128 focused tests pass across four suites (including a RED → GREEN stalled-host-lookup regression),
apps/kimi-codeandpackages/kap-servertypecheck, and the CLI production build passes. Full Vitest matrix was not rerun for this rebase.Checklist
gen-changesetsskill; added a patch changeset for the CLI package.gen-docsskill; no documentation update is needed for this internal shutdown policy.