Skip to content

[upstream #16551] 16551: Disconnect snapshot can overwrite a just-settled terminal row #232

Description

@berry-13

Raised by the local cross-family review of LibreChat-AI#16551 (finding local:846b9aa:L-001).

The allSubscribersLeft partial save in api/server/controllers/agents/request.js reads the job record, checks isSettledJobRecord, then calls saveMessage with unfinished: true, error: false. A completion, error or abort path that settles the same response between that read and the write is overwritten by the stale snapshot, so the turn reopens as unfinished on reload.

The window predates LibreChat-AI#16551: on dev the disconnect save has no settled check at all, and LibreChat-AI#16551 narrows it to the settling path's own commit span. Closing it needs the write itself to be conditional (an upsert that refuses to replace a row that is no longer unfinished, or a job-epoch claim taken atomically with the save), which is a storage contract change in packages/data-schemas rather than part of the compaction abort fix.

Expected: a disconnect snapshot never replaces a row a terminal writer already settled.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: apireviewctl followups statearea: packagesreviewctl followups stateblocked: root openreviewctl followups statebugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions