Skip to content

Roll back localRefs on failed GetObject exchange#6932

Merged
kmccarp merged 4 commits intomainfrom
fix-rpc-localrefs-rollback
Apr 4, 2026
Merged

Roll back localRefs on failed GetObject exchange#6932
kmccarp merged 4 commits intomainfrom
fix-rpc-localrefs-rollback

Conversation

@kmccarp
Copy link
Copy Markdown
Contributor

@kmccarp kmccarp commented Mar 10, 2026

Summary

  • Roll back localRefs on failed GetObject exchanges (both Java and TypeScript sender sides)
  • Add snapshot()/rollbackTo() to TypeScript ReferenceMap
  • Add test assertion for ref rollback after send failure

Problem

When a GetObject exchange fails mid-serialization, the sender's localRefs retains refs assigned during the failed exchange. The sender had already cleaned up remoteObjects on failure (forcing a full ADD on retry), but the stale refs in localRefs remained. On subsequent exchanges, the sender would encounter the same objects, find them already in localRefs, 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 GetObject exchange. 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

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
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Mar 10, 2026
@zieka zieka self-requested a review March 10, 2026 22:50
@kmccarp kmccarp merged commit deca4de into main Apr 4, 2026
1 check passed
@kmccarp kmccarp deleted the fix-rpc-localrefs-rollback branch April 4, 2026 03:22
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants