Add compute runtime sleep guard package#81
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
Summary by CodeRabbit
WalkthroughThis PR introduces a new 🚥 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)
✨ Simplify code
Comment |
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 `@packages/compute/src/scale-to-zero.ts`:
- Around line 142-144: The current waitUntil call discards the promise returned
by Promise.resolve(promise).finally(...), which can create an unhandled
rejection; change the flow so the finally-attached promise cannot produce an
unhandled rejection — e.g., after Promise.resolve(promise).finally(() =>
guard.release()) attach a .catch(() => {}) to consume any rejection from the
finalizer chain (or otherwise capture the returned promise) so Node won’t flag
unhandled rejections; update the invocation in waitUntil where promise and
guard.release() are 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5616e5ab-19b2-4a29-8cde-666a961beaa0
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
docs/architecture/package-structure.mdpackage.jsonpackages/compute/AGENTS.mdpackages/compute/README.mdpackages/compute/package.jsonpackages/compute/src/index.tspackages/compute/src/scale-to-zero-control.tspackages/compute/src/scale-to-zero.tspackages/compute/tests/scale-to-zero.test.tspackages/compute/tsconfig.jsonpackages/compute/tsdown.config.ts
|
Reviewed with the local code-review. Fixed the waitUntil rejection handling, added a regression test, and made the PR workflow run compute test/build too. Local checks and CI are green. |
Adds
@prisma/computeas a publishable runtime utility package for Prisma Compute applications. The first API helps application code keep an instance awake while background work is active, without adding any CLI command surface.Changes
packages/computeas an ESM TypeScript library withtsdownbuild output, package-local verification guidance, and workspace lockfile metadata.ScaleToZeroGuardandwaitUntilfrompackages/compute/src/index.ts. Both write paired acquire/release signals to the Prisma Compute runtime endpoint, no-op outside the runtime, and supportAbortSignalas a safety bound for dangling guards.waitUntilfire-and-forget semantics.Why
Prisma Compute can sleep and resume applications from memory snapshots after short idle periods. Request-adjacent background work needs an explicit keep-awake signal so it is not interrupted when the request completes. The guard uses immediate one-byte writes so acquisition and release are ordered with user code, while
AbortSignal.timeout(ms)lets callers bound guard lifetime if a code path does not reach release.