Skip to content

Streamable HTTP server replays the event named by Last-Event-ID on resume #1577

Todo

Description

@v3rysp3d

Describe the bug

When a client reconnects with Last-Event-ID, LocalSessionManager (no external EventStore) replays the cached events starting at that id, not after it. The client gets the last event it already read a second time.

CachedTx::sync(index) in crates/rmcp/src/transport/streamable_http_server/session/local.rs skips index - front.index cached events and sends the rest, so the event at index is sent again. Both resume paths in LocalSessionWorker::resume pass last_event_id.index to it.

The standalone GET stream also has two events with id 0: the priming event that tower.rs puts in front of the stream, and the first cached event (CachedTx::new_common starts at index 0). Last-Event-ID: 0 is ambiguous there.

To Reproduce

On main (3725772), in the completed_channel_resume_tests style:

  1. create_local_session, establish_request_wise_channel, register a progress token for it.
  2. Send two progress notifications. The stream holds 0/0 (priming), 1/0, 2/0.
  3. worker.resume("1/0".parse().unwrap()).

The resumed stream yields 1/0 and 2/0.

Over HTTP: open the standalone GET stream, let the server send one notification, read its id:, drop the connection, GET again with that id in Last-Event-ID. The notification arrives again.

Expected behavior

Only 2/0 is replayed. The transport spec says the header "indicate[s] the last event ID it received" and the server may "replay messages that would have been sent after the last event ID". EventStore::replay_events_after already has this contract; the in-memory path differs from it.

Impact

The rmcp client keeps the id of the last event it read and reconnects with it, and does not drop repeats. After a reconnect it handles that event twice: a notification handler runs twice, and a server request routed to the request's stream (elicitation, sampling) is executed twice.

Additional context

#1165 reported the same offset together with another change and was closed as stale without review. The other change landed in #1487.

I have a fix with tests and can open a PR.

AI disclosure: found, reproduced and written up with Claude Code (an AI coding agent).

Activity

  1. github-actions commented on Dec 5, 2026

    @github-actions
    Contributor

    @connor4312 is on triage rotation this week and is the reviewer for this one.

    Automated classification did not run for this one, so it needs a full manual pass.

    Automated triage. Labels are a first pass and the assigned maintainer has the final say.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions