Skip to content

[Server] Stop concurrent writes from corrupting session files - #500

Open
chr-hertel wants to merge 4 commits into
mainfrom
fix-concurrent-session-writes
Open

[Server] Stop concurrent writes from corrupting session files#500
chr-hertel wants to merge 4 commits into
mainfrom
fix-concurrent-session-writes

Conversation

@chr-hertel

@chr-hertel chr-hertel commented Sep 7, 2026

Copy link
Copy Markdown
Member

Fixes #498.

FileSessionStore::write() used one temporary filename per session, so concurrent writers published each other's half-written files. Each write now gets its own; gc() collects the leftovers a killed write leaves behind.

Session::readData() threw JsonException on an empty or truncated payload, taking down a request whose tool call had already succeeded. It now degrades to an empty session, which is what the existing !is_array($decoded) branch was always meant to do.

Note: the corrupt payload is dropped silently — Session has no logger.

Give each write its own temporary file, collect the leftovers in gc(),
and degrade an undecodable payload to an empty session.
@chr-hertel chr-hertel added bug Something isn't working Server Issues & PRs related to the Server component labels Sep 7, 2026
proc_get_status() reaps the process before PHP 8.3, so the later
proc_close() reported -1 and the unit job failed on 8.1 and 8.2.
An empty file is what an interrupted write leaves behind, never a stored
payload, and the interface asks for false when nothing was read.
Comment thread src/Server/Session/Session.php Outdated
Comment thread src/Server/Session/FileSessionStore.php Outdated
Comment thread src/Server/Session/FileSessionStore.php Outdated
Comment thread src/Server/Session/FileSessionStore.php Outdated
Co-authored-by: Christopher Hertel <mail@christopher-hertel.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Server] Concurrent requests corrupt the session file in FileSessionStore, crashing Session::readData() with JsonException

1 participant