feat: add request timing markers#105
Conversation
📝 WalkthroughWalkthrough
ChangesRequest Performance Instrumentation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/integration/opencode-loop.integration.test.ts (1)
267-278: ⚡ Quick winConsider increasing the timeout for more reliable CI execution.
The current polling timeout is 500ms (20 iterations × 25ms). This may be insufficient in slow CI environments or under heavy load, potentially causing flaky test failures. Additionally, when the timeout expires, returning an empty string provides no diagnostic information about whether the file never appeared or simply didn't contain the required text.
💡 Suggested improvements
-async function waitForFileText(path: string, requiredText?: string): Promise<string> { - for (let i = 0; i < 20; i++) { +async function waitForFileText(path: string, requiredText?: string, timeoutMs = 2000): Promise<string> { + const iterations = Math.ceil(timeoutMs / 50); + for (let i = 0; i < iterations; i++) { if (existsSync(path)) { const text = readFileSync(path, "utf8"); if (text.length > 0 && (requiredText === undefined || text.includes(requiredText))) { return text; } } - await new Promise((resolve) => setTimeout(resolve, 25)); + await new Promise((resolve) => setTimeout(resolve, 50)); } return existsSync(path) ? readFileSync(path, "utf8") : ""; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/integration/opencode-loop.integration.test.ts` around lines 267 - 278, The waitForFileText function has an insufficient timeout of 500ms total (20 iterations × 25ms), which can cause flaky tests in CI environments. Increase the timeout by either increasing the number of iterations (the loop counter 20) or the sleep duration (25ms), or both. Additionally, when the function times out and is about to return at the end, instead of returning an empty string, throw an error or return a meaningful diagnostic message that indicates whether the file never appeared or if it appeared but didn't contain the required text. This will provide better visibility into test failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/integration/opencode-loop.integration.test.ts`:
- Around line 267-278: The waitForFileText function has an insufficient timeout
of 500ms total (20 iterations × 25ms), which can cause flaky tests in CI
environments. Increase the timeout by either increasing the number of iterations
(the loop counter 20) or the sleep duration (25ms), or both. Additionally, when
the function times out and is about to return at the end, instead of returning
an empty string, throw an error or return a meaningful diagnostic message that
indicates whether the file never appeared or if it appeared but didn't contain
the required text. This will provide better visibility into test failures.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f493fee9-a533-4d99-8926-e47098187551
📒 Files selected for processing (4)
src/plugin.tssrc/utils/perf.tstests/integration/opencode-loop.integration.test.tstests/unit/perf.test.ts
PR B for the perf work.\n\nAdds CURSOR_ACP_TIMING=1 request timing logs with ordered phase timelines, fixes repeated marker accounting, and records streaming phases for request parse, prompt/backend resolution, child creation, first stdout byte, first SSE write, and request completion.\n\nVerification:\n- bun test tests/unit/perf.test.ts\n- bun test tests/integration/opencode-loop.integration.test.ts\n- npm run build\n- npm test