{"action":"opened","issue":{"url":"https://api.github.com/repos/biosustain/potion-node/issues/29","repository_url":"https://api.github.com/repos/biosustain/potion-node","labels_url":"https://api.github.com/repos/biosustain/potion-node/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/biosustain/potion-node/issues/29/comments","events_url":"https://api.github.com/repos/biosustain/potion-node/issues/29/events","html_url":"https://github.com/biosustain/potion-node/issues/29","id":227639526,"number":29,"title":"Race condition leading to unpopulated items returned by promise ","user":{"login":"lyschoening","id":74085,"avatar_url":"https://avatars3.githubusercontent.com/u/74085?v=3","gravatar_id":"","url":"https://api.github.com/users/lyschoening","html_url":"https://github.com/lyschoening","followers_url":"https://api.github.com/users/lyschoening/followers","following_url":"https://api.github.com/users/lyschoening/following{/other_user}","gists_url":"https://api.github.com/users/lyschoening/gists{/gist_id}","starred_url":"https://api.github.com/users/lyschoening/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lyschoening/subscriptions","organizations_url":"https://api.github.com/users/lyschoening/orgs","repos_url":"https://api.github.com/users/lyschoening/repos","events_url":"https://api.github.com/users/lyschoening/events{/privacy}","received_events_url":"https://api.github.com/users/lyschoening/received_events","type":"User","site_admin":false},"labels":[{"id":308215602,"url":"https://api.github.com/repos/biosustain/potion-node/labels/Bug","name":"Bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-10T10:48:29Z","updated_at":"2017-05-10T10:48:29Z","closed_at":null,"body":"We have a query (that we run repetitively) that resolves an array of items each of which also has recursively resolving parents. We encountered a race conditions where sometimes some of the items in the array have parents that are not fully resolved. These parents have been constructed but the data for them has not been loaded. \r\n\r\nLooking at the code, it seems most likely that the race condition happens because:\r\n\r\n1. Items are added to `PotionBase.cache` as soon as the constructor is initialized\r\n2. The resolution of children uses `PotionBase.fetch()`\r\n3. `PotionBase.fetch()` returns items from the cache, regardless of whether their promise has been resolved or not.\r\n\r\nAssuming that circular references don't happen, the problem could be solved by placing a promise for the item (rather than the item itself) onto the cache."}}
{"actor":{"display_login":"lyschoening"}}