Skip to content

docs(rivetkit): document keepAwake/waitUntil counter-arm race and surface bridge errors#4759

Merged
NathanFlurry merged 1 commit intomainfrom
sleep-cleanup/14-document-counter-arm-race
Apr 27, 2026
Merged

docs(rivetkit): document keepAwake/waitUntil counter-arm race and surface bridge errors#4759
NathanFlurry merged 1 commit intomainfrom
sleep-cleanup/14-document-counter-arm-race

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 24, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 24, 2026

PR Review: docs(rivetkit): document keepAwake/waitUntil counter-arm race and surface bridge errors

Overall: Good improvement — tightens error handling and documents a subtle timing invariant that would otherwise be easy to misread as a bug.


Strengths

  • Documentation quality: The counter-arm race comment is precise. It names the race, explains why it is safe (sleep timer debounce), and states the accepted trade-off. Developers reading this won't chase a phantom bug.
  • Error handling: Replacing bare void callNative(...) with .catch() is correct. Unhandled rejections on fire-and-forget calls can surface as noisy warnings in Node and now they're handled explicitly.
  • Consistent pattern: Both keepAwake and waitUntil follow identical error handling logic, which is good for maintainability.
  • Expected error filtering: Silencing isClosedTaskRegistrationError for shutdown-path noise is the right call per CLAUDE.md conventions (expected teardown errors should not clutter warnings).

Issues

Minor: Comment style does not follow CLAUDE.md conventions

CLAUDE.md specifies: write comments as normal, complete sentences and avoid fragmented structures with parentheticals and dashes.

The keepAwake comment uses parenthetical annotations like (acceptable) and (default 30s), and semicolons as sentence separators. These should be normal complete sentences. Not a blocker but worth tidying before merge.

Minor: waitUntil comment references keepAwake for full context

The waitUntil comment is terser and says "same counter-arm race as keepAwake". A reader must context-switch between methods to understand either. Consider making each comment self-contained, or placing a single shared explanation above both methods.

Cosmetic: void removal is intentional but undocumented

In keepAwake, the original void callNative(...) loses its void. This is correct (the .catch() now handles the rejection), but a reviewer might flag it as accidental. No action needed, just noting it is deliberate.


Test Coverage

Existing driver tests in actor-sleep-db.test.ts cover the waitUntil happy path and rejection-during-shutdown scenarios. No new tests are strictly required for this documentation and error-logging change. However, these paths are currently untested:

  • Warn log fires when callNative rejects with a non-shutdown error.
  • isClosedTaskRegistrationError errors are silently swallowed with no spurious warnings during shutdown.

Low priority given the code paths are simple, but worth a follow-up to guard against future regression.


Summary

Correct and safe. Two minor points worth addressing before merge: comment style per CLAUDE.md, and optionally making the waitUntil comment self-contained. No blocking issues.

@NathanFlurry NathanFlurry force-pushed the sleep-cleanup/14-document-counter-arm-race branch from c76a37f to 3d62102 Compare April 24, 2026 13:16
@NathanFlurry NathanFlurry force-pushed the sleep-cleanup/13-alarm-test-deterministic branch from 3f88401 to 0e7355d Compare April 24, 2026 13:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

Preview packages published to npm

Install with:

npm install rivetkit@pr-4759

All packages published as 0.0.0-pr.4759.2611022 with tag pr-4759.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-2611022
docker pull rivetdev/engine:full-2611022
Individual packages
npm install rivetkit@pr-4759
npm install @rivetkit/react@pr-4759
npm install @rivetkit/rivetkit-napi@pr-4759
npm install @rivetkit/workflow-engine@pr-4759

Base automatically changed from sleep-cleanup/13-alarm-test-deterministic to main April 27, 2026 07:13
@NathanFlurry NathanFlurry merged commit 8635c7d into main Apr 27, 2026
23 of 27 checks passed
@NathanFlurry NathanFlurry deleted the sleep-cleanup/14-document-counter-arm-race branch April 27, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant