{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/17974","labels_url":"https://api.github.com/repos/akka/akka/issues/17974/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/17974/comments","events_url":"https://api.github.com/repos/akka/akka/issues/17974/events","html_url":"https://github.com/akka/akka/pull/17974","id":94603838,"number":17974,"title":"=per #17959 PersistentFsmActor persists StateChangeEvent on stay","user":{"login":"leonidb","id":2226323,"avatar_url":"https://avatars.githubusercontent.com/u/2226323?v=3","gravatar_id":"","url":"https://api.github.com/users/leonidb","html_url":"https://github.com/leonidb","followers_url":"https://api.github.com/users/leonidb/followers","following_url":"https://api.github.com/users/leonidb/following{/other_user}","gists_url":"https://api.github.com/users/leonidb/gists{/gist_id}","starred_url":"https://api.github.com/users/leonidb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonidb/subscriptions","organizations_url":"https://api.github.com/users/leonidb/orgs","repos_url":"https://api.github.com/users/leonidb/repos","events_url":"https://api.github.com/users/leonidb/events{/privacy}","received_events_url":"https://api.github.com/users/leonidb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akka/akka/labels/t:persistence","name":"t:persistence","color":"CCCCCC"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-07-12T22:05:48Z","updated_at":"2015-08-13T06:33:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/17974","html_url":"https://github.com/akka/akka/pull/17974","diff_url":"https://github.com/akka/akka/pull/17974.diff","patch_url":"https://github.com/akka/akka/pull/17974.patch"},"body":"Prevent PersistentFSM from saving state change event on stay"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/130554047","html_url":"https://github.com/akka/akka/pull/17974#issuecomment-130554047","issue_url":"https://api.github.com/repos/akka/akka/issues/17974","id":130554047,"user":{"login":"leonidb","id":2226323,"avatar_url":"https://avatars.githubusercontent.com/u/2226323?v=3","gravatar_id":"","url":"https://api.github.com/users/leonidb","html_url":"https://github.com/leonidb","followers_url":"https://api.github.com/users/leonidb/followers","following_url":"https://api.github.com/users/leonidb/following{/other_user}","gists_url":"https://api.github.com/users/leonidb/gists{/gist_id}","starred_url":"https://api.github.com/users/leonidb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonidb/subscriptions","organizations_url":"https://api.github.com/users/leonidb/orgs","repos_url":"https://api.github.com/users/leonidb/repos","events_url":"https://api.github.com/users/leonidb/events{/privacy}","received_events_url":"https://api.github.com/users/leonidb/received_events","type":"User","site_admin":false},"created_at":"2015-08-13T06:33:19Z","updated_at":"2015-08-13T06:33:19Z","body":"@ktoso @patriknw \r\nAfter giving it some thought, I think I was wrong. In the regular FSM every command handled by the actor resets the timeout, and then the new state either sets the timeout again or leaves it as is.\r\n\r\nSo, rewriting the explanation of the test failure from my last commit:\r\n1. ```AddItem``` is handled -> ```StateChangeEvent``` is persisted, setting a timeout to 1 sec\r\n2. ```GetCurrentCart``` is handled -> ```StateChangeEvent``` is not persisted since the event doesn't  cause a state to change, doesn't emit any domain events and doesn't set the timeout to anything.\r\n In the usual ```FSM``` flow not setting timeout resets the previously set timeout.\r\n In ```PersistentFSM``` prior to this bug fix a None timeout was persisted, leading to recovery without state timeout.\r\nAfter the bug fix ```PersistentFSM``` doesn't store the ```StateChangeEvent```, leading to recovery with the timeout of 1 sec.\r\n\r\nCan be fixed by storing the last applied timeout  in a ```var``` in ```PersistentFSM``` and using it to determine if the new state changes the previously set timeout. "}}