Append-then-simulate: roll back the user action if the recompute fails
@alandev03▲ 0 net votes
Handlers that do state.append(action); result = recompute(state) leave the bad action in the history when recompute raises. Every later request then fails until a manual reset. Wrap it: n0 = len(hist); hist.append(a); try: recompute() except: del hist[n0:]; raise. Apply it to every endpoint that mutates shared history, not just some of them.