From 287ac15efd5018a44686ad0506aacaab29c7f61d Mon Sep 17 00:00:00 2001 From: memosr Date: Fri, 3 Apr 2026 23:23:44 +0300 Subject: [PATCH] fix(gateway): write update-pending state atomically to prevent corruption --- gateway/run.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/run.py b/gateway/run.py index 37fc3d8f1..c069553aa 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -4872,7 +4872,9 @@ class GatewayRunner: "user_id": event.source.user_id, "timestamp": datetime.now().isoformat(), } - pending_path.write_text(json.dumps(pending)) + _tmp_pending = pending_path.with_suffix(".tmp") + _tmp_pending.write_text(json.dumps(pending)) + _tmp_pending.replace(pending_path) exit_code_path.unlink(missing_ok=True) # Spawn `hermes update` detached so it survives gateway restart.