{"action":"created","issue":{"url":"https://api.github.com/repos/js-data/js-data/issues/63","labels_url":"https://api.github.com/repos/js-data/js-data/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/js-data/js-data/issues/63/comments","events_url":"https://api.github.com/repos/js-data/js-data/issues/63/events","html_url":"https://github.com/js-data/js-data/issues/63","id":59219810,"number":63,"title":"Find ocassionally returns an undefined document","user":{"login":"jozsi","id":840815,"avatar_url":"https://avatars.githubusercontent.com/u/840815?v=3","gravatar_id":"","url":"https://api.github.com/users/jozsi","html_url":"https://github.com/jozsi","followers_url":"https://api.github.com/users/jozsi/followers","following_url":"https://api.github.com/users/jozsi/following{/other_user}","gists_url":"https://api.github.com/users/jozsi/gists{/gist_id}","starred_url":"https://api.github.com/users/jozsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jozsi/subscriptions","organizations_url":"https://api.github.com/users/jozsi/orgs","repos_url":"https://api.github.com/users/jozsi/repos","events_url":"https://api.github.com/users/jozsi/events{/privacy}","received_events_url":"https://api.github.com/users/jozsi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-27T10:44:01Z","updated_at":"2015-02-27T16:09:40Z","closed_at":null,"body":"Hello,\r\n\r\nSometimes, especially on mobile Safari, `find` promise is resolved with an `undefined` document even though it exists - right before and right after it returns the expected document. No other operations are made meanwhile, just reading.\r\n\r\nThe used library versions are:\r\n- js-data: 1.4.0\r\n- js-data-schema: 1.0.0\r\n- js-data-localforage: 1.0.0\r\n- localforage: 1.2.2\r\n\r\nI am using the `localforage` adapter with default configuration.\r\n\r\nCode snippet:\r\n```js\r\nAppState\r\n  .find(userID)\r\n  .then(function(state) {\r\n    console.log(\"This is sometimes undefined:\", state);\r\n  })\r\n  .catch(function(err) {\r\n    console.log(\"I would expect to receive an error:\", err);\r\n  })\r\n;\r\n```\r\n\r\nIt worths mentioning that the `AppState` resource does **not** have a defined `schema`, only `methods`.\r\n\r\nAny ideas?\r\n\r\nThanks,\r\nJózsi"},"comment":{"url":"https://api.github.com/repos/js-data/js-data/issues/comments/76419532","html_url":"https://github.com/js-data/js-data/issues/63#issuecomment-76419532","issue_url":"https://api.github.com/repos/js-data/js-data/issues/63","id":76419532,"user":{"login":"jmdobry","id":1213510,"avatar_url":"https://avatars.githubusercontent.com/u/1213510?v=3","gravatar_id":"","url":"https://api.github.com/users/jmdobry","html_url":"https://github.com/jmdobry","followers_url":"https://api.github.com/users/jmdobry/followers","following_url":"https://api.github.com/users/jmdobry/following{/other_user}","gists_url":"https://api.github.com/users/jmdobry/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdobry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdobry/subscriptions","organizations_url":"https://api.github.com/users/jmdobry/orgs","repos_url":"https://api.github.com/users/jmdobry/repos","events_url":"https://api.github.com/users/jmdobry/events{/privacy}","received_events_url":"https://api.github.com/users/jmdobry/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T16:09:40Z","updated_at":"2015-02-27T16:09:40Z","body":"Please report the output of the following:\r\n\r\n```\r\n// should be a number (timestamp) if the item is in the store already\r\nconsole.log('completedQuery: ', store.store[AppState.name].completedQueries[userID]);\r\n\r\n// should be an object if the item is in the store already\r\nconsole.log('item: ', AppState.get(userID));\r\n\r\n// Should delegate to js-data-localforage if !store.store[AppState.name].completedQueries[userID]\r\n// Should resolve with the cached item if !!store.store[AppState.name].completedQueries[userID]\r\nAppState\r\n  .find(userID)\r\n  .then(function(state) {\r\n    console.log(\"This is sometimes undefined:\", state);\r\n\r\n    // Change \"localforage\" to whatever name you used to register the js-data-localforage adapter\r\n    var key = store.getAdapter('localforage').getIdPath(AppState, {}, userId);\r\n\r\n    console.log('key: ', key);\r\n\r\n    localforage.getItem(key, function (err, v) {\r\n      if (err) {\r\n        console.log(err);\r\n      } else {\r\n        console.log('getItem: ', v);\r\n      }\r\n    });\r\n  })\r\n  .catch(function(err) {\r\n    console.log(\"I would expect to receive an error:\", err);\r\n  })\r\n;\r\n```"}}