Skip to content

Conversation

@RedaRahmani
Copy link

Summary

This PR fixes a subtle bug in the Rust and Go LaserStream SDKs where stream-write updates were not persisted across reconnects.

Previously:

The SDKs cached the initial SubscribeRequest and reused it on every reconnect.

write / StreamHandle::write only sent updates to the live stream, without updating that cached request.

After a disconnect + reconnect, the client silently reverted to the original subscription, dropping all stream-write changes.

What I changed

Rust (rust/src/client.rs)

  • Added a small helper merge_subscribe_requests(...) that:

  • Merges new filters (accounts, slots, txs, blocks, etc.) into the cached SubscribeRequest.

  • Updates commitment and from_slot when present.

  • Preserves the internal slot subscription used for replay.

  • In subscribe, when we receive a write via write_rx.recv():

  • We now call merge_subscribe_requests(&mut current_request, &write_request, ...) before forwarding it to the stream.

  • Reconnects now use the latest merged subscription, not just the initial one.

Go (go/laserstream.go)

  • Added mergeSubscribeRequests(base, update, internalSlotID) with similar behavior to Rust.

  • In Client.Write:

  • We now merge req into c.originalRequest while keeping the internal slot tracker.

  • Then we send req on writeChan as before.

  • On reconnect, connectAndStream reuses c.originalRequest, which now reflects all stream-write updates.

Behavior after this PR

  • Stream-write updates (new filters, commitment changes, from_slot updates, etc.) persist across reconnects in both Rust and Go SDKs.

  • Existing replay behavior (fork-safe from_slot, internal slot tracking) is preserved.

@RedaRahmani
Copy link
Author

Hi @hetdagli234 ,
When you have a moment, I’d really appreciate a review on this PR. It fixes a subtle bug where stream-write updates were lost after reconnects in both the Rust and Go SDKs.

@hetdagli234
Copy link
Collaborator

Hey, thanks for the contribution, can you please add tests for both?

@RedaRahmani
Copy link
Author

Hey @hetdagli234 , thanks for the quick feedback!
I’ve added unit + property tests for the Rust SDK around merge_subscribe_requests (see attached screenshot of cargo test).
I’m working on the Go SDK tests now and will push them shortly.
image

@RedaRahmani
Copy link
Author

RedaRahmani commented Nov 24, 2025

hey @hetdagli234 , I’ve also added Go unit tests for mergeSubscribeRequests (mirroring the Rust coverage).
If you’d like me to extend coverage or take a different testing approach, I’m happy to adjust.

@RedaRahmani
Copy link
Author

Hi @hetdagli234 , just a gentle ping on this PR when you have a moment 🙌
I’ve added the Rust unit + property tests and the Go unit tests for mergeSubscribeRequests, and CI is green.
If you’d like me to adjust the approach or extend coverage anywhere, I’m happy to update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants