Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ metadata:
- **`bun:sqlite` file handles persist after `db.close()` on Windows.** `rmSync` on the temp dir in `afterEach` can throw `EBUSY`. Set `PRAGMA journal_mode = DELETE` to avoid WAL/SHM files, and wrap `rmSync` in try/catch.
- **macOS `/var` → `/private/var` symlink breaks temp dir path comparisons.** `mkdtempSync` returns `/var/folders/...` but `process.cwd()` after `chdir()` resolves to `/private/var/...`. Always wrap with `realpathSync`. Invisible on ubuntu-only PR CI — only surfaces in release builds.
- **Don't test that well-known tools exist on PATH** (e.g. `expect(resolveCommand("bun")).toBe("bun")`) — asserts CI environment state, not logic, and fails when tools are installed via shims. Delete such tests; the null-return and `.exe`-fallback tests already cover the real logic.
- **Attach `.catch()` at promise creation, not at `await`.** When firing an async call in parallel (`const p = asyncFn()`) and awaiting later, Bun reports an unhandled rejection in the window between creation and the later `await p.catch(...)`. Fix: `const p = asyncFn().catch(() => null)` then `await p`.
15 changes: 15 additions & 0 deletions src/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { logError } from "../helpers/log";
import { formatJSON, isAgentContext } from "../helpers/output";
import { findProjectRoot } from "../helpers/paths";
import { getConfiguredBaseBranch } from "../helpers/project-config";
import { detectStack } from "../helpers/stack-detect";
import { trackCheckResult } from "../helpers/telemetry";

const maxWarningsOption = new Option(
Expand Down Expand Up @@ -60,6 +61,14 @@ export function registerCheckCommand(program: Command) {
return;
}

// Run stack detection in parallel with rule loading — both are fast I/O
// and independent. Stack info enriches the telemetry event at the end.
// Bounded with a timeout so pathological projects can't stall the exit.
const stackPromise = Promise.race([
detectStack(projectRoot),
Bun.sleep(500).then(() => null),
]).catch(() => null);

Comment thread
coderabbitai[bot] marked this conversation as resolved.
let loadResults;
const loadStart = performance.now();
try {
Expand Down Expand Up @@ -146,6 +155,9 @@ export function registerCheckCommand(program: Command) {
reportConsole(result, opts.verbose ?? false, summary);
}

// Await stack detection (started in parallel with rule loading above).
const stack = await stackPromise;

// Track aggregate check results (no file paths or violation content)
trackCheckResult({
total_rules: summary.total,
Expand All @@ -164,6 +176,9 @@ export function registerCheckCommand(program: Command) {
files_scanned: filterFiles.length,
load_duration_ms: loadDurationMs,
check_duration_ms: Math.round(result.totalDurationMs),
languages: stack?.languages,
runtimes: stack?.runtimes,
frameworks: stack?.frameworks,
});

const exitCode = getExitCode(result, summary);
Expand Down
Loading