-
-
Notifications
You must be signed in to change notification settings - Fork 126
feat(publisher): change cloudflare durable object cleanup #1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(publisher): change cloudflare durable object cleanup #1266
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughRenames the resume cleanup configuration from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
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 |
Summary of ChangesHello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the cleanup mechanism for Cloudflare Durable Objects by renaming a key configuration parameter and simplifying the alarm scheduling logic. The change aims to make the cleanup process more predictable and easier to understand, ensuring that inactive Durable Objects are properly purged at a defined interval, which has also been adjusted to 12 hours by default. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request refactors the cleanup mechanism for Cloudflare Durable Objects by replacing the inactiveDataRetentionTime option with cleanupIntervalSeconds. This change simplifies the alarm scheduling logic, making it a periodic check for inactivity, which is a clearer and more robust approach. The changes are consistently applied across the implementation, tests, and documentation. My only suggestion is to improve the clarity of an inline comment in the documentation to better explain the new cleanup behavior to users.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/publisher-durable-object/src/resume-storage.test.ts (1)
296-314: Time-window assertion could be made more robustThe test correctly asserts that the alarm delay matches
cleanupIntervalSeconds, but usingDate.now()at assertion time with a tight ±1s window introduces a small flakiness risk if the test environment is slow.Consider either:
- Using fake timers (
vi.useFakeTimers()/vi.setSystemTime) so bothsetAlarmand the expectations share a controlled clock, or- Capturing a single
const now = Date.now()before constructingResumeStorageand reusingnowin both the implementation expectation and bounds, to decouple from test runtime variance.packages/publisher-durable-object/src/resume-storage.ts (1)
20-30: NewcleanupIntervalSecondsoption and scheduling look consistent; consider validating the valueThe introduction of
cleanupIntervalSecondswith a12 * 60 * 60default, wiring it through the constructor, and using it directly inscheduleAlarm()all look consistent with the intended “how often to check for cleanup” semantics and with the updated tests/docs.One improvement to consider: guard against invalid values for
cleanupIntervalSeconds(e.g.,<= 0,NaN,Infinity) before using it inDate.now() + this.cleanupIntervalSeconds * 1000. Today, a misconfigured value could result in an immediate or effectively never-scheduled alarm, or even aNaNtimestamp.A simple pattern could be:
const rawInterval = options.cleanupIntervalSeconds if (!Number.isFinite(rawInterval) || rawInterval! <= 0) { this.cleanupIntervalSeconds = 12 * 60 * 60 } else { this.cleanupIntervalSeconds = rawInterval }This keeps the public surface the same while making the runtime more resilient to configuration mistakes.
Also applies to: 42-42, 58-58, 234-235
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/content/docs/helpers/publisher.md(1 hunks)packages/publisher-durable-object/src/resume-storage.test.ts(1 hunks)packages/publisher-durable-object/src/resume-storage.ts(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: publish-commit
- GitHub Check: lint
- GitHub Check: test
🔇 Additional comments (1)
apps/content/docs/helpers/publisher.md (1)
236-239: Docs example aligned with implementation defaultThe added
cleanupIntervalSeconds: 12 * 60 * 60and the “default: 12 hours” comment are consistent with the newResumeStoragedefault and naming, so the Cloudflare Durable Object example stays in sync with the runtime behavior.
Deploying orpc with
|
| Latest commit: |
92d047a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://446443a4.orpc-1qh.pages.dev |
| Branch Preview URL: | https://feat-publisher-cloudflare-du.orpc-1qh.pages.dev |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/experimental-pino
@orpc/experimental-publisher
@orpc/experimental-publisher-durable-object
@orpc/experimental-ratelimit
@orpc/react
@orpc/react-query
@orpc/experimental-react-swr
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fastify
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.