Repository navigation
fix(scripts): bound :agent runs with a portable timeout so a hung suite fails loudly - #853
Conversation
|
Warning Review limit reached
More reviews will be available in 52 minutes and 42 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a Node.js log wrapper for agent commands, switches ChangesAgent script runner with timeout and log capture
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Verification complete on both named targets:
|
size-limit report 📦
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/config-loader
@prisma-next/emitter
@prisma-next/language-server
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@scripts/run-logged.mjs`:
- Line 13: The timeoutSeconds variable at line 13 does not validate the parsed
timeout value, allowing invalid numbers like NaN, Infinity, zero, or negative
values to be used, which can cause incorrect timeout behavior. After converting
the environment variable to a number using Number(env.AGENT_CMD_TIMEOUT_SECONDS
?? 3600), add validation to ensure the result is a positive finite number, and
fall back to the default value (3600) if the parsed value is invalid. Use
Number.isFinite() and a check for positive values to validate the timeoutSeconds
assignment before it is used.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 12c3b95e-9bde-4bd0-8481-d337b0e98b3f
📒 Files selected for processing (4)
.agents/rules/running-tests.mdcpackage.jsonscripts/run-logged.mjsscripts/run-logged.test.mjs
3ee5275 to
d4724a0
Compare
…te fails loudly The :agent wrappers redirect a slow command to a log file and write the exit code to a sibling .exit marker. When vitest intermittently freezes after printing its summary (an unresolved PGlite/WASM teardown abort on Linux), the inner `pnpm <cmd>` never returns, the .exit marker is never written, and the wrapper blocks forever. Replace the inline-shell wrappers with a portable Node wrapper, scripts/ run-logged.mjs, that runs the command under a hard timeout (default 60 min, override via AGENT_CMD_TIMEOUT_SECONDS). On timeout it kills the child process group, records 124 in the .exit file, and returns — so a hang now fails loudly instead of hanging. `timeout`/`gtimeout` are not portable (absent on macOS), so the bound is enforced in Node. This also removes the `status=$?` shell idiom, which is a read-only variable in zsh and broke the wrappers there (supersedes the standalone rename in #842). Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
d4724a0 to
03169cc
Compare
Problem
The root
:agentscript wrappers (test:integration:agent,test:packages:agent, …) redirect a slow command to a timestamped log underwip/and write its exit code to a sibling.exitmarker, so an agent can fire-and-check rather than stream output. The inline shell was:On an intermittent vitest hang after it prints its full passing summary (
Test Files … passed,Duration …s), the innerpnpm <cmd>never returns. Thestatus=$?; echo … > …exit; exittail never runs, the.exitmarker is never written, and the wrapper blocks forever until something external kills it.Diagnosis
I could not reproduce the post-summary hang on macOS in 10 full integration runs — the process always exits after the summary (cleanly, or non-zero on a test failure, in which case the
.exitis written correctly). The hang is intermittent and matches the documented Linux-only PGlite (WASM) teardown abort (jit_page_->allocations_.erase) thattest/integration/vitest.config.tsalready tries to mitigate with--no-memory-protection-keysand that still "intermittently aborts on Linux" per that config's own comment. It lives in the@prisma/devdependency's WASM teardown, not in this repo's test teardown: I traced every suspected leak (thepg.Pool/pg.Clientin the postgres driver tests and integration runtime helper, everyMongoMemoryReplSet) and each is closed —driver.close()ends the pool/client, and every replset has a matchingstop(). So there is no missingafterAllto fix here.Fix
Replace the eight inline-shell
:agentwrappers with one portable Node wrapper,scripts/run-logged.mjs, that runs the command under a hard timeout (default 60 min, override withAGENT_CMD_TIMEOUT_SECONDS). On timeout it kills the child process group (so turbo/vitest grandchildren die too), records124in the.exitfile, and returns. A hang now fails loudly with a non-zero.exitinstead of blocking forever — the reliable backstop the root-cause (a dependency's intermittent WASM teardown) doesn't give us.timeout/gtimeoutare not portable (absent on macOS, where agents run), so the bound is enforced in Node rather than via thetimeoutbinary.Bonus: this drops the
status=$?idiom, which is a read-only variable in zsh and broke the wrappers there. That makes it a superset of #842 (the standalonestatus→rcrename) — #842 can be closed in favour of this.Verification
scripts/run-logged.test.mjs(wired intotest:scripts) covers all four exit paths: success →.exit0; failure →.exitis the child code; timeout →.exit124 +TIMEOUTmarker; and idempotency (the SIGKILL-triggeredclosecan't overwrite124).build:agentreturns rc 0 and writes.exit0;test:integration:agentreturns rc 1 on a failing run and writes.exit1 (faithful pass-through). Both print thelog:line and capture full output.Out of scope / follow-up
The package-level vitest configs (run by
test:packages) lack the--no-memory-protection-keysflag that integration/e2e set, which is the most likely contributor to the Linuxtest:packageshang. Propagating it is a separate, low-risk change tracked as a follow-up; it only reduces the abort, so the timeout wrapper here is the actual backstop.Summary by CodeRabbit
:agentruns (default 5 minutes; configurable); on timeout the process is terminated and the run exits with 124..exitfile isn’t overwritten).