refactor(rivetkit): deprecate setPreventSleep to no-op in TypeScript#4747
Conversation
|
PR Review: refactor(rivetkit): deprecate setPreventSleep to no-op in TypeScript The direction here is sound. keepAwake(promise) is a strictly better API than a stateful boolean flag, and the deprecation is appropriate. However, there are a few issues worth addressing before this merges. HIGH SEVERITY: agent-os calls become silent no-ops on the native path File: rivetkit-typescript/packages/rivetkit/src/agent-os/actor/index.ts syncPreventSleep() at line ~108 calls c.setPreventSleep(shouldPrevent) to hold the actor awake while activeSessionIds, activeProcesses, hooks, or shells are active. After this PR, that call is a no-op on the native NAPI path. Individual hooks are wrapped in c.waitUntil(promise) which covers hook-lifetime work. But activeSessionIds and activeProcesses are long-lived Sets that are not wrapped in keepAwake. Actors on the native path may sleep prematurely while sessions or processes are still active. Recommendation: Before merging, migrate agent-os to keepAwake with a long-lived promise per tracked session/process, or use noSleep on the native path if the actor should never idle-sleep during active work. MEDIUM SEVERITY: No runtime signal when setPreventSleep is called on the native path instance/mod.ts retains the full live setPreventSleep / preventSleep implementation. On the legacy engine-runner path, setPreventSleep(true) still genuinely blocks sleep. On the native NAPI path it is silently ignored. A compile-time @deprecated alone will not surface this to users at runtime. Recommendation: Emit a console.warn or structured log when setPreventSleep is called on the native path so users get a runtime signal, not just a type-checker hint. MEDIUM SEVERITY: keepAwake is still marked @deprecated in instance/mod.ts instance/mod.ts line ~1610 has JSDoc marking keepAwake as deprecated in favor of setPreventSleep, the exact inverse of this PR intent. workflow/context.ts correctly removes the deprecated annotation from keepAwake but instance/mod.ts was not updated. LOW SEVERITY: Minor doc inconsistencies
The agent-os regression is the main blocker. Everything else is cleanup. |
3e970bd to
fa41ec7
Compare
6966cdb to
8650b44
Compare
fa41ec7 to
7ece97e
Compare
31f3a57 to
dfa956c
Compare
b1d5d9d to
70609c2
Compare
dfa956c to
181bb0f
Compare
Preview packages published to npmInstall with: npm install rivetkit@pr-4747All packages published as Engine binary is shipped via Docker images: docker pull rivetdev/engine:slim-40e2709
docker pull rivetdev/engine:full-40e2709Individual packagesnpm install rivetkit@pr-4747
npm install @rivetkit/react@pr-4747
npm install @rivetkit/rivetkit-napi@pr-4747
npm install @rivetkit/workflow-engine@pr-4747 |

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: