-
-
Notifications
You must be signed in to change notification settings - Fork 821
fix(runner): immediate poll to decrease restore time #2516
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
Conversation
🦋 Changeset detectedLatest commit: 57daf07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
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 |
Walkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli-v3/src/utilities/windows.ts (1)
21-38
: Fix potential infinite loop when terminal width is very small or unavailable.availableWidth can become ≤ 0 (e.g., very small terminals), making the while condition always true even for empty strings.
-function truncateMessage(msg: string, maxLength?: number): string { - const terminalWidth = maxLength ?? process.stdout.columns ?? 80; - const availableWidth = terminalWidth - 5; // Reserve some space for the spinner and padding +function truncateMessage(msg: string, maxLength?: number): string { + const rawWidth = maxLength ?? process.stdout.columns ?? 80; + const terminalWidth = + typeof rawWidth === "number" && Number.isFinite(rawWidth) ? Math.max(rawWidth, 10) : 80; + // Reserve some space for the spinner and padding; clamp to avoid non‑positive widths + const availableWidth = Math.max(terminalWidth - 5, 1); const visibleLength = getVisibleLength(msg); if (visibleLength <= availableWidth) { return msg; } // We need to truncate based on visible characters, but preserve ANSI sequences // Simple approach: truncate character by character until we fit let truncated = msg; - while (getVisibleLength(truncated) > availableWidth - 3) { + // If we have almost no room, just show ellipsis + if (availableWidth <= 3) { + return "..."; + } + while (getVisibleLength(truncated) > Math.max(availableWidth - 3, 0)) { truncated = truncated.slice(0, -1); } return truncated + "..."; }
🧹 Nitpick comments (7)
.changeset/sharp-cheetahs-end.md (1)
5-6
: Clarify claim and trim trailing space.Wording “by 5s” reads absolute; suggest “up to 5s” to better reflect variability. Also remove trailing space on Line 6.
- - Reduce restore times by 5s due to immediate polling + - Reduce restore times by up to 5s due to immediate polling - - Fix `s is not a function` and surface underlying error messages + - Fix `s is not a function` and surface underlying error messagesscripts/publish-prerelease.sh (2)
26-28
: Update the comment to match the new default.Comment still refers to v3.
-# Use the first argument as version or 'v3-prerelease' if not available +# Use the first argument as version or 'v4-prerelease' if not available version=${1:-'v4-prerelease'}
51-52
: Quote $version to avoid accidental word-splitting/globbing.Defensive shell hygiene; no behavior change.
-echo "Running: pnpm exec changeset version --snapshot $version" -if output=$(pnpm exec changeset version --snapshot $version 2>&1); then +echo "Running: pnpm exec changeset version --snapshot \"$version\"" +if output=$(pnpm exec changeset version --snapshot "$version" 2>&1); then @@ -echo "Going to run: pnpm exec changeset publish --no-git-tag --snapshot --tag $version" +echo "Going to run: pnpm exec changeset publish --no-git-tag --snapshot --tag \"$version\"" @@ - pnpm exec changeset publish --no-git-tag --snapshot --tag $version + pnpm exec changeset publish --no-git-tag --snapshot --tag "$version"Also applies to: 71-75
packages/cli-v3/src/utilities/windows.ts (2)
62-69
: Also truncate logged messages when spinner wasn’t started.Keeps output width consistent with active spinner path.
- if (!isActive) { + if (!isActive) { // Spinner was never started, just display the message if (msg) { - log.message(msg); + log.message(truncateMessage(msg)); } return; }
76-83
: Mirror truncation for message() when inactive.Same rationale as stop().
- if (!isActive) { + if (!isActive) { // Spinner was never started, just display the message if (msg) { - log.message(msg); + log.message(truncateMessage(msg)); } return; }packages/cli-v3/src/entryPoints/managed/controller.ts (1)
487-508
: Handle string descriptions from socket disconnect.description can be a plain string; current code would log undefined.
- const parseDescription = (): + const parseDescription = (): | { description: string; context?: string; } | undefined => { if (!description) { return undefined; } + if (typeof description === "string") { + return { description }; + } + if (description instanceof Error) { return { description: description.toString(), }; } return { description: description.description, context: description.context ? String(description.context) : undefined, }; };packages/cli-v3/src/entryPoints/managed/execution.ts (1)
899-958
: LGTM — call sites updated; optional: add in-flight guard for snapshot polls
- Signature is backward compatible. rg found calls at:
- packages/cli-v3/src/entryPoints/managed/controller.ts:517 — processEnvOverrides("socket disconnected", true)
- packages/cli-v3/src/entryPoints/managed/execution.ts:868 — processEnvOverrides("restore")
- packages/cli-v3/src/entryPoints/managed/execution.ts:1195 — processEnvOverrides("snapshots since error")
- Optional: prevent overlapping snapshot polls by guarding fetchAndProcessSnapshotChanges with a flag and try/finally to clear it on every exit. Example pattern:
- private fetchingSnapshots = false;
- public async fetchAndProcessSnapshotChanges(source: string) {
if (this.fetchingSnapshots) return;
this.fetchingSnapshots = true;
try { /* existing logic */ } finally { this.fetchingSnapshots = false; }
}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/sharp-cheetahs-end.md
(1 hunks)packages/cli-v3/src/entryPoints/managed/controller.ts
(1 hunks)packages/cli-v3/src/entryPoints/managed/execution.ts
(2 hunks)packages/cli-v3/src/utilities/windows.ts
(1 hunks)scripts/publish-prerelease.sh
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}
: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations
Files:
packages/cli-v3/src/entryPoints/managed/execution.ts
packages/cli-v3/src/utilities/windows.ts
packages/cli-v3/src/entryPoints/managed/controller.ts
🧬 Code graph analysis (1)
packages/cli-v3/src/entryPoints/managed/execution.ts (1)
packages/cli-v3/src/entryPoints/managed/overrides.ts (1)
Metadata
(1-13)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: typecheck / typecheck
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/cli-v3/src/entryPoints/managed/controller.ts (1)
517-517
: Good call: trigger immediate snapshot poll on disconnect.Passing the boolean to processEnvOverrides should shave the idle window after a disconnect.
This reduces restore times by up to 5s across all runs.
Also fixes the dreaded
s is not a function
error - turns out it came from@clack/prompts
when calling stop on a spinner that hadn't started yet.