-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[DO] Adding Durable Object base class #18423
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
Conversation
Deploying cloudflare-docs with
|
| Latest commit: |
0ada43d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8053b844.cloudflare-docs-7ou.pages.dev |
| Branch Preview URL: | https://jun-do-base-object-cleanup.cloudflare-docs-7ou.pages.dev |
|
|
||
| - <code> serializeAttachment(value <Type text="any" />)</code>: <Type text="void" /> | ||
|
|
||
| - Keeps a copy of `value` in memory (not on disk) to survive hibernation. The value can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), which is true of most types. |
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.
Keeps a copy of
valuein memory (not on disk)
@MellowYarker does a user need to worry about the case where the runtime crashes and potentially loses the in-memory copy? Does this count against the memory consumed by the Durable Object?
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.
does a user need to worry about the case where the runtime crashes and potentially loses the in-memory copy
Yes, this will not survive a "hard" eviction. The only way this survives eviction is if we do a "soft" eviction (no requests for 10 seconds).
Does this count against the memory consumed by the Durable Object?
Not when the DO is hibernating. When the DO is awake and the WebSocket is in memory (it was just created, or received a message, or was brought back in via state.getWebSockets() it does contribute (because it lives in the isolate).
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.
@Oxyjun I would add that
Keeps a copy of
valueassociated with the WebSocket to survive hibernation. The value can be any type supported by the structured clone algorithm, which is true of most types. If the value needs to be durable please useDurableObjectStorage(hyperlink the Durable Object storage reference)
This reverts commit 6088c07.
Actioning other PR comments.
Co-authored-by: marciocloudflare <[email protected]>
Summary
DurableObjectbase class chapter, and listing its methods, including previously missingfetchandalarm.DurableObjectbase class chapter and Best Practices/Use WebSockets/serializeAttachmentdeserializeAttachmentScreenshots (optional)
Documentation checklist