Roll back localRefs on failed GetObject exchange#6932
Merged
Conversation
When a GetObject exchange fails mid-serialization, the sender's localRefs retains refs assigned during the failed exchange. On subsequent exchanges, the sender sends pure references for objects the remote never received, causing "Received a reference to an object that was not previously sent". Fix by snapshotting the ref count before the exchange and rolling back any refs added during a failed exchange, on both Java and TypeScript sender sides. Fixes moderneinc/customer-requests#1977
zieka
approved these changes
Mar 10, 2026
sambsnyd
approved these changes
Mar 31, 2026
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.
Summary
localRefson failedGetObjectexchanges (both Java and TypeScript sender sides)snapshot()/rollbackTo()to TypeScriptReferenceMapProblem
When a
GetObjectexchange fails mid-serialization, the sender'slocalRefsretains refs assigned during the failed exchange. The sender had already cleaned upremoteObjectson failure (forcing a full ADD on retry), but the stale refs inlocalRefsremained. On subsequent exchanges, the sender would encounter the same objects, find them already inlocalRefs, and send pure references — but the remote never received the original objects. This causes"Received a reference to an object that was not previously sent"on the receiver side.Solution
Snapshot the ref count before each
GetObjectexchange. On failure, remove any refs added during the exchange by rolling back to the saved count. This ensures subsequent exchanges re-send full objects instead of dangling pure references.Applied symmetrically to both the Java (
GetObject.Handler) and TypeScript (get-object.ts) sender sides.Test plan
Existing
RewriteRpcTesttests passAdded assertion to
sendFailureCleansUpRemoteObjectsverifying localRefs rollbackTypeScript typechecks pass
Fixes https://github.com/moderneinc/customer-requests/issues/1977