Skip to content

[s2 lite] clamp=true ignored on read sessions — returns 416 instead of clamping to stream tail #316

@NiklasDah

Description

@NiklasDah

Description

Read sessions on S2 Lite with clamp=true still return 416 Range Not Satisfiable when the requested starting position is beyond the stream tail (e.g., reading from seq_num=0 on an empty stream). According to the docs, clamp should silently adjust the starting point to the stream tail instead of erroring.

Reproduce

  1. Create a new (empty) stream
  2. Start a read session with seq_num=0 and clamp=true:
    GET /v1/streams/{stream_id}/records?seq_num=0&clamp=true
    
  3. Observe a 416 response instead of a clamped read session:
    RangeNotSatisfiableError: Range not satisfiable: requested position is beyond the stream tail (seq_num=0).
    Use 'clamp: true' to start from the tail instead.
    

The error message itself even suggests using clamp: true — which is already set.

Expected Behavior

Per the docs:

When clamp is enabled and the starting point is beyond the stream tail, the session should begin reading from the tail rather than returning an error.

The read session should open successfully, clamped to the current tail, and follow for new records (if unbounded).

Actual Behavior

The clamp parameter is ignored. The server returns 416 Range Not Satisfiable with a response suggesting the caller use clamp: true — the very flag that was already provided.

request{method=GET uri=/v1/streams/HxmuEnT9XeZ7wPfnmk-GE/records?seq_num=0&clamp=true version=HTTP/1.1}:
  tower_http::trace::on_response: finished processing request latency=0 ms status=416

SDK trace:

RangeNotSatisfiableError: Range not satisfiable: requested position is beyond the stream tail (seq_num=0).
  Use 'clamp: true' to start from the tail instead.
    at streamRead (.../node_modules/@s2-dev/streamstore/dist/esm/lib/stream/transport/fetch/shared.js:29:19)

Notes

  • Reproduced with ghcr.io/s2-streamstore/s2:0.29.21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions