A reader asked for the HTTP version of my earlier SQLite crash test: kill the process after the external action succeeds but before the client saves its result.
I ran it with a local HTTP receiver that increments a counter. The receiver commits to its own SQLite database and sends HTTP 200. The LangGraph client reads that response, then exits with os._exit(86) before saving the local receipt or returning the task result. A new client process resumes the same checkpointed thread. The operation ID and amount come from the saved input.
After the crash, all four cases had one receiver-side effect, a committed local intent, and no local result. The difference was what the client and receiver did on resume:
| Recovery behavior | Total POSTs | Receiver effects | Resumed result |
|---|
| Resend; receiver applies each request | 2 | 2 | 2 |
| Resend; receiver deduplicates the operation ID | 2 | 1 | Original receipt: 1 |
| Look up the operation; receiver confirms its receipt | 1 | 1 | Original receipt: 1 |
| Look up the operation; lookup is inconclusive | 1 | 1 | Unresolved; no second POST |
In the last case, I made the fixture return 404 for a receipt that existed. That models an unavailable outcome without assuming a particular provider's consistency behavior. The client kept the intent unresolved. It did not treat the lookup miss as permission to repeat the effect.
The relevant crash boundary was inside the task, between reading the successful POST response and committing the local result. Neither the intent record nor the graph checkpoint contains the receiver's answer at that point. A positive lookup can recover it if the API exposes a stable operation identity and a receipt you can validate. An inconclusive lookup leaves work to reconcile.
I also retried the deduplicated operation with a different amount: the fixture returned 409 and kept the effect count at one. Reusing an operation ID needs an argument check as well as a saved result.
Versions: LangGraph 1.2.24, langgraph-checkpoint-sqlite 3.1.3, Python 3.14.7, SQLite 3.53.4. Four isolated local cases, using real loopback HTTP and fresh client processes. The receiver stayed alive. This covers client process exit; provider failures, concurrent clients, idempotency-key expiry and power loss remain untested. No model calls or payment service were involved.
LangGraph persistence model · Task idempotency guidance
I used AI assistance for the fixture and write-up.
Reproduction: save the complete script below as langgraph_http_crash_repro.py, then run it in a Python virtual environment. It creates the receiver and client databases in temporary directories, starts a receiver on 127.0.0.1, and stops each server and removes its files after the test. The first client process intentionally exits with code 86 in each case. The script asserts the before/after counts and prints JSON results.
python3 -m venv .venv
.venv/bin/python -m pip install langgraph==1.2.24 langgraph-checkpoint-sqlite==3.1.3
.venv/bin/python langgraph_http_crash_repro.py
Complete tested script:
"""Synthetic local HTTP effect and LangGraph client-process crash experiment.
Install: pip install langgraph==1.2.24 langgraph-checkpoint-sqlite==3.1.3
Run: python langgraph_http_crash_repro.py
No model or external service. The receiver only listens on 127.0.0.1.
The intentional crash occurs after reading a successful HTTP response and
before writing the result into the client database / returning the task result.
"""
from __future__ import annotations
import http.client
import json
import os
from pathlib import Path
import sqlite3
import subprocess
import sys
import tempfile
import threading
from http.server import BaseHTTPRequestHandler, HTTPServer
from importlib.metadata import version
def request(port, method, path, payload=None):
# http.client does not use inherited HTTP_PROXY variables.
connection = http.client.HTTPConnection("127.0.0.1", port, timeout=5)
try:
body = json.dumps(payload) if payload is not None else None
connection.request(method, path, body, {"Content-Type": "application/json"})
response = connection.getresponse()
return response.status, json.loads(response.read())
finally:
connection.close()
class Receiver(BaseHTTPRequestHandler):
def log_message(self, *_):
pass
def send_json(self, code, payload):
body = json.dumps(payload).encode()
self.send_response(code)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_POST(self):
data = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
op_id, amount = data["op_id"], data["amount"]
self.server.posts += 1
with sqlite3.connect(self.server.database) as db:
prior = db.execute("SELECT amount, result FROM effects WHERE op_id=? ORDER BY result LIMIT 1", (op_id,)).fetchone()
if self.server.mode == "receiver_dedup" and prior:
if prior[0] != amount:
self.send_json(409, {"error": "operation arguments differ"})
return
result = prior[1]
else:
result = db.execute("SELECT COALESCE(SUM(amount),0)+? FROM effects", (amount,)).fetchone()[0]
db.execute("INSERT INTO effects(op_id,amount,result) VALUES(?,?,?)", (op_id,amount,result))
db.commit()
self.send_json(200, {"op_id": op_id, "amount": amount, "result": result})
def do_GET(self):
self.server.lookups += 1
op_id = self.path.removeprefix("/operations/")
# Deliberately hide an existing receipt to model an inconclusive lookup.
# This is fixture behavior, not a claim about a real provider's API.
if self.server.mode == "lookup_inconclusive":
self.send_json(404, {"status": "not_visible"})
return
with sqlite3.connect(self.server.database) as db:
row = db.execute("SELECT amount,result FROM effects WHERE op_id=? ORDER BY result LIMIT 1", (op_id,)).fetchone()
self.send_json(200 if row else 404, {"op_id": op_id, "amount": row[0], "result": row[1]} if row else {"status": "absent"})
def child(directory, port, mode, phase):
from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.func import entrypoint, task
directory = Path(directory)
local = directory / "client.db"
with sqlite3.connect(local) as db:
db.execute("CREATE TABLE IF NOT EXISTS operations(op_id TEXT PRIMARY KEY, amount INTEGER, result INTEGER)")
@task
def effect(data):
with sqlite3.connect(local) as db:
previous = db.execute("SELECT amount,result FROM operations WHERE op_id=?", (data["op_id"],)).fetchone()
if previous:
if previous[0] != data["amount"]:
raise ValueError("local operation arguments differ")
if previous[1] is not None:
return previous[1]
else:
db.execute("INSERT INTO operations VALUES(?,?,NULL)", (data["op_id"],data["amount"]))
if previous and mode.startswith("lookup_"):
status, receipt = request(port, "GET", "/operations/" + data["op_id"])
if status != 200:
# Absence does not authorize replay in this fixture contract.
raise RuntimeError("UNRESOLVED_EFFECT: lookup did not confirm an outcome")
else:
status, receipt = request(port, "POST", "/effects", data)
assert status == 200, (status, receipt)
assert (receipt["op_id"],receipt["amount"]) == (data["op_id"],data["amount"])
if phase == "crash":
os._exit(86)
with sqlite3.connect(local) as db:
db.execute("UPDATE operations SET result=? WHERE op_id=?", (receipt["result"],data["op_id"]))
return receipt["result"]
with SqliteSaver.from_conn_string(str(directory / "graph.db")) as checkpointer:
@entrypoint(checkpointer=checkpointer)
def flow(data):
return effect(data).result()
config = {"configurable": {"thread_id": "synthetic-run"}}
try:
output = flow.invoke({"op_id": "op-A", "amount": 1} if phase == "crash" else None, config)
print(json.dumps({"status": "completed", "result": output}))
except RuntimeError as exc:
if "UNRESOLVED_EFFECT" not in str(exc):
raise
print(json.dumps({"status": "unresolved", "result": None}))
def main():
results = []
env = os.environ.copy()
for key in list(env):
if key.startswith("LANGSMITH_") or key.startswith("LANGCHAIN_"):
del env[key]
env.update(LANGSMITH_TRACING="false", LANGCHAIN_TRACING_V2="false")
for mode in ["blind_replay", "receiver_dedup", "lookup_confirmed", "lookup_inconclusive"]:
with tempfile.TemporaryDirectory(prefix="langgraph-http-") as temporary:
directory = Path(temporary)
receiver_db = directory / "receiver.db"
with sqlite3.connect(receiver_db) as db:
db.execute("CREATE TABLE effects(op_id TEXT, amount INTEGER, result INTEGER)")
server = HTTPServer(("127.0.0.1", 0), Receiver)
server.database, server.mode = receiver_db, mode
server.posts, server.lookups = 0, 0
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
port = server.server_address[1]
try:
args = [sys.executable, __file__, "child", str(directory), str(port), mode]
crash = subprocess.run(args + ["crash"], env=env, capture_output=True, text=True, timeout=30)
assert crash.returncode == 86, (mode,crash.returncode,crash.stderr)
with sqlite3.connect(receiver_db) as db:
after_crash_effects = db.execute("SELECT COUNT(*) FROM effects").fetchone()[0]
with sqlite3.connect(directory / "client.db") as db:
after_crash_intents = db.execute("SELECT COUNT(*) FROM operations").fetchone()[0]
after_crash_receipts = db.execute("SELECT COUNT(*) FROM operations WHERE result IS NOT NULL").fetchone()[0]
assert (after_crash_effects,after_crash_intents,after_crash_receipts) == (1,1,0)
resume = subprocess.run(args + ["resume"], env=env, capture_output=True, text=True, timeout=30, check=True)
outcome = json.loads(resume.stdout)
with sqlite3.connect(receiver_db) as db:
effects = db.execute("SELECT COUNT(*) FROM effects").fetchone()[0]
with sqlite3.connect(directory / "client.db") as db:
local_receipts = db.execute("SELECT COUNT(*) FROM operations WHERE result IS NOT NULL").fetchone()[0]
row = {"mode":mode, "crash_exit_code":crash.returncode,
"after_crash":{"receiver_effects":after_crash_effects,"local_intents":after_crash_intents,
"local_receipts":after_crash_receipts},
"after_resume":{"receiver_effects":effects,"local_receipts":local_receipts,
"post_requests":server.posts,"lookup_requests":server.lookups,**outcome}}
expected = {"blind_replay":(2,2,"completed"),"receiver_dedup":(1,1,"completed"),
"lookup_confirmed":(1,1,"completed"),"lookup_inconclusive":(1,None,"unresolved")}[mode]
assert (effects,outcome["result"],outcome["status"]) == expected, row
if mode == "receiver_dedup":
status, _ = request(port,"POST","/effects",{"op_id":"op-A","amount":5})
with sqlite3.connect(receiver_db) as db:
final_effects = db.execute("SELECT COUNT(*) FROM effects").fetchone()[0]
assert (status,final_effects) == (409,1)
row["different_arguments_check"] = {"http_status":status,"receiver_effects":final_effects}
results.append(row)
finally:
server.shutdown()
server.server_close()
thread.join()
print(json.dumps({"langgraph":version("langgraph"),"checkpoint_sqlite":version("langgraph-checkpoint-sqlite"),
"python":sys.version.split()[0],"sqlite":sqlite3.sqlite_version,
"transport":"real loopback HTTP; receiver stays alive while client process exits and restarts",
"fixture_scope":"synthetic integer increment; local process exit; no model/external provider/power-loss test",
"results":results,"temporary_servers_stopped_and_files_removed":True},indent=2))
if __name__ == "__main__":
if len(sys.argv)>1 and sys.argv[1]=="child":
child(sys.argv[2],int(sys.argv[3]),sys.argv[4],sys.argv[5])
else:
main()