{"action":"created","issue":{"url":"https://api.github.com/repos/trello/scientist/issues/10","repository_url":"https://api.github.com/repos/trello/scientist","labels_url":"https://api.github.com/repos/trello/scientist/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/trello/scientist/issues/10/comments","events_url":"https://api.github.com/repos/trello/scientist/issues/10/events","html_url":"https://github.com/trello/scientist/issues/10","id":157826142,"number":10,"title":"When object returned by 'use' is mutated before, 'try' returns. Hence comparison is sabotaged.","user":{"login":"soswow","id":108065,"avatar_url":"https://avatars.githubusercontent.com/u/108065?v=3","gravatar_id":"","url":"https://api.github.com/users/soswow","html_url":"https://github.com/soswow","followers_url":"https://api.github.com/users/soswow/followers","following_url":"https://api.github.com/users/soswow/following{/other_user}","gists_url":"https://api.github.com/users/soswow/gists{/gist_id}","starred_url":"https://api.github.com/users/soswow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soswow/subscriptions","organizations_url":"https://api.github.com/users/soswow/orgs","repos_url":"https://api.github.com/users/soswow/repos","events_url":"https://api.github.com/users/soswow/events{/privacy}","received_events_url":"https://api.github.com/users/soswow/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-06-01T05:28:17Z","updated_at":"2016-06-03T17:34:15Z","closed_at":null,"body":"If subj is not enough:\r\nwe have 'use' and 'try' functions returning promises (so, async = true). I'll call these funcs as **main** and **secondary**.\r\nThere is Function **consumer** that uses **main**. I am introducing parallel call, so now **consumer** uses result of **science()** call.\r\n**Consumer** mutates object **A** after promise from **main** is resolved. But **secondary** hasn't been resolved yet. \r\n**Secondary** is resolved with object **B** and scientist grabs it to compare with **A** (which at this point has been mutated already). Result is - false positive mismatch. \r\n\r\nWe currently solve it by cloning deep object **A** on the way from **science()**.\r\n```javascript\r\nreturn science(name, function (experiment) {\r\n// ... \r\n}).then(function(result) {\r\n    return _.cloneDeep(result);\r\n});\r\n```\r\n\r\nI thought you might be interested in making some general solution since our scenario seems quite real."},"comment":{"url":"https://api.github.com/repos/trello/scientist/issues/comments/223642931","html_url":"https://github.com/trello/scientist/issues/10#issuecomment-223642931","issue_url":"https://api.github.com/repos/trello/scientist/issues/10","id":223642931,"user":{"login":"DavidTPate","id":2223120,"avatar_url":"https://avatars.githubusercontent.com/u/2223120?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidTPate","html_url":"https://github.com/DavidTPate","followers_url":"https://api.github.com/users/DavidTPate/followers","following_url":"https://api.github.com/users/DavidTPate/following{/other_user}","gists_url":"https://api.github.com/users/DavidTPate/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidTPate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidTPate/subscriptions","organizations_url":"https://api.github.com/users/DavidTPate/orgs","repos_url":"https://api.github.com/users/DavidTPate/repos","events_url":"https://api.github.com/users/DavidTPate/events{/privacy}","received_events_url":"https://api.github.com/users/DavidTPate/received_events","type":"User","site_admin":false},"created_at":"2016-06-03T17:34:15Z","updated_at":"2016-06-03T17:34:15Z","body":"Would this be something where [Object.assign()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) would be beneficial?\r\n\r\nPrior to invocation the incoming arguments could be \"cloned\" to address this. This would mean a performance delay there, but I'm not sure the impact."}}
{"actor":{"display_login":"DavidTPate"}}