Fix encoding of weak actor handles - #2398
Draft
Neverlord wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes serialization of weak_actor_ptr (including expired handles) by delegating weak-handle encoding/decoding to the actor_handle_codec, ensuring down/exit messages remain serializable even when no strong reference exists locally (per #2397).
Changes:
- Route
serializer::value(weak_actor_ptr)/deserializer::value(weak_actor_ptr)throughactor_handle_codecinstead of upgrading to a strong handle. - Extend
actor_handle_codecanddetail::default_actor_handle_codecwith explicitsave/loadforweak_actor_ptr, including proper handling for expired weak handles (serialize ID+node without registering). - Add a new regression test covering strong handles, valid weak handles, and expired weak handles across binary and JSON formats; remove now-unneeded
save_actor/load_actorfree functions from the public API.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| libcaf_core/caf/serializer.cpp | Uses actor_handle_codec to serialize weak_actor_ptr directly. |
| libcaf_core/caf/deserializer.cpp | Uses actor_handle_codec to deserialize weak_actor_ptr directly. |
| libcaf_core/caf/actor_handle_codec.hpp | Makes weak-handle save/load part of the codec vtable (pure virtual). |
| libcaf_core/caf/detail/default_actor_handle_codec.hpp | Declares weak-handle save/load overrides. |
| libcaf_core/caf/detail/default_actor_handle_codec.cpp | Implements weak-handle save/load, including expired weak-handle behavior. |
| libcaf_core/caf/detail/stringification_inspector.cpp | Implements weak-handle save/load for stringification codec. |
| libcaf_core/caf/actor_control_block.hpp | Removes public declarations of save_actor/load_actor. |
| libcaf_core/caf/actor_control_block.cpp | Removes definitions of save_actor/load_actor. |
| libcaf_core/caf/detail/default_actor_handle_codec.test.cpp | Adds tests for strong/weak/expired-weak roundtrips and encoding expectations. |
| libcaf_core/CMakeLists.txt | Adds the new test file to the build. |
| CHANGELOG.md | Documents removal of save_actor/load_actor from the public API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Neverlord
force-pushed
the
gh-2397-weak-pointer-serialization
branch
from
April 30, 2026 11:42
8030967 to
f921357
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2398 +/- ##
==========================================
+ Coverage 73.08% 73.23% +0.15%
==========================================
Files 636 636
Lines 30525 30551 +26
Branches 3342 3344 +2
==========================================
+ Hits 22310 22375 +65
+ Misses 6304 6260 -44
- Partials 1911 1916 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2397.