{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/1223","repository_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler","labels_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/1223/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/1223/comments","events_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/1223/events","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/1223","id":200649718,"number":1223,"title":"FindOrCreate does not return errors on connector error","user":{"login":"jamesjjk","id":13486303,"avatar_url":"https://avatars1.githubusercontent.com/u/13486303?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesjjk","html_url":"https://github.com/jamesjjk","followers_url":"https://api.github.com/users/jamesjjk/followers","following_url":"https://api.github.com/users/jamesjjk/following{/other_user}","gists_url":"https://api.github.com/users/jamesjjk/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesjjk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesjjk/subscriptions","organizations_url":"https://api.github.com/users/jamesjjk/orgs","repos_url":"https://api.github.com/users/jamesjjk/repos","events_url":"https://api.github.com/users/jamesjjk/events{/privacy}","received_events_url":"https://api.github.com/users/jamesjjk/received_events","type":"User","site_admin":false},"labels":[{"id":40062716,"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/labels/bug","name":"bug","color":"b60205","default":true}],"state":"closed","locked":false,"assignee":{"login":"dhmlau","id":25489897,"avatar_url":"https://avatars0.githubusercontent.com/u/25489897?v=3","gravatar_id":"","url":"https://api.github.com/users/dhmlau","html_url":"https://github.com/dhmlau","followers_url":"https://api.github.com/users/dhmlau/followers","following_url":"https://api.github.com/users/dhmlau/following{/other_user}","gists_url":"https://api.github.com/users/dhmlau/gists{/gist_id}","starred_url":"https://api.github.com/users/dhmlau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhmlau/subscriptions","organizations_url":"https://api.github.com/users/dhmlau/orgs","repos_url":"https://api.github.com/users/dhmlau/repos","events_url":"https://api.github.com/users/dhmlau/events{/privacy}","received_events_url":"https://api.github.com/users/dhmlau/received_events","type":"User","site_admin":false},"assignees":[{"login":"dhmlau","id":25489897,"avatar_url":"https://avatars0.githubusercontent.com/u/25489897?v=3","gravatar_id":"","url":"https://api.github.com/users/dhmlau","html_url":"https://github.com/dhmlau","followers_url":"https://api.github.com/users/dhmlau/followers","following_url":"https://api.github.com/users/dhmlau/following{/other_user}","gists_url":"https://api.github.com/users/dhmlau/gists{/gist_id}","starred_url":"https://api.github.com/users/dhmlau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhmlau/subscriptions","organizations_url":"https://api.github.com/users/dhmlau/orgs","repos_url":"https://api.github.com/users/dhmlau/repos","events_url":"https://api.github.com/users/dhmlau/events{/privacy}","received_events_url":"https://api.github.com/users/dhmlau/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2017-01-13T14:58:04Z","updated_at":"2017-03-17T01:37:52Z","closed_at":"2017-03-17T01:37:52Z","body":"### Bug or feature request\r\n- [x] Bug\r\n\r\n### Description of feature (or steps to reproduce if bug)\r\nThere is a bug in dao.js that does not produce an error when it should on a connector issue. This yields issues for mongodb in particular. \r\n\r\nReference as to fix:\r\nhttps://github.com/strongloop/loopback-connector-mongodb/issues/296\r\n\r\nErrors are overwritten by Model.notifyObserversOf should insert conditional and return just after findOrCreate callback (please :)\r\n\r\n```\r\nfunction _findOrCreate(query, data, currentInstance) {\r\n    var modelName = self.modelName;\r\n    function findOrCreateCallback(err, data, created) {\r\n      console.log(!!err); //INSERT HERE: if (err) { return cb(err); }\r\n      var context = {\r\n        Model: Model,\r\n        data: data,\r\n        isNewInstance: created,\r\n        hookState: hookState,\r\n        options: options,\r\n      };\r\n      Model.notifyObserversOf('loaded', context, function(err) {\r\n        if (err) return cb(err);\r\n\r\n        var obj, Model = self.lookupModel(data);\r\n```\r\n\r\n\r\n### Additional information (Node.js version, LoopBack version, etc)\r\nThis Error is present in:\r\n- 2.53.0 (one I'm using)\r\nBut also in your 3.0.0\r\n"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/comments/287242970","html_url":"https://github.com/strongloop/loopback-datasource-juggler/issues/1223#issuecomment-287242970","issue_url":"https://api.github.com/repos/strongloop/loopback-datasource-juggler/issues/1223","id":287242970,"user":{"login":"rmg","id":17978,"avatar_url":"https://avatars1.githubusercontent.com/u/17978?v=3","gravatar_id":"","url":"https://api.github.com/users/rmg","html_url":"https://github.com/rmg","followers_url":"https://api.github.com/users/rmg/followers","following_url":"https://api.github.com/users/rmg/following{/other_user}","gists_url":"https://api.github.com/users/rmg/gists{/gist_id}","starred_url":"https://api.github.com/users/rmg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmg/subscriptions","organizations_url":"https://api.github.com/users/rmg/orgs","repos_url":"https://api.github.com/users/rmg/repos","events_url":"https://api.github.com/users/rmg/events{/privacy}","received_events_url":"https://api.github.com/users/rmg/received_events","type":"User","site_admin":false},"created_at":"2017-03-17T01:37:52Z","updated_at":"2017-03-17T01:37:52Z","body":"@jamesjjk I couldn't find your name in the CLA db, but given how busy you seem to be and how trivial the fix is I just went ahead and \"fixed this myself\" in e9baea77e028b63fce2d0ce3ee405a5eebf8132e."}}
{"actor":{"display_login":"rmg"}}