{"action":"created","issue":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4643","labels_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4643/labels{/name}","comments_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4643/comments","events_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4643/events","html_url":"https://github.com/pouchdb/pouchdb/issues/4643","id":121083244,"number":4643,"title":"Error 500 with CORS warning","user":{"login":"simonaberry","id":5033446,"avatar_url":"https://avatars.githubusercontent.com/u/5033446?v=3","gravatar_id":"","url":"https://api.github.com/users/simonaberry","html_url":"https://github.com/simonaberry","followers_url":"https://api.github.com/users/simonaberry/followers","following_url":"https://api.github.com/users/simonaberry/following{/other_user}","gists_url":"https://api.github.com/users/simonaberry/gists{/gist_id}","starred_url":"https://api.github.com/users/simonaberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonaberry/subscriptions","organizations_url":"https://api.github.com/users/simonaberry/orgs","repos_url":"https://api.github.com/users/simonaberry/repos","events_url":"https://api.github.com/users/simonaberry/events{/privacy}","received_events_url":"https://api.github.com/users/simonaberry/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-08T19:42:35Z","updated_at":"2015-12-13T01:34:36Z","closed_at":null,"body":"I am getting repetitive 500 errors (v5.1.0) and would appreciate some guidance on how to debug further. \r\n\r\n```\r\nUncaught (in promise) e\r\nerror: true\r\nmessage: \"Database encountered an unknown error\"\r\nname: \"unknown_error\"\r\nresult: Object\r\ndoc_write_failures: 0\r\ndocs_read: 0\r\ndocs_written: 0\r\nend_time: Tue Dec 08 2015 21:00:53 GMT+0200 (SAST)\r\nerrors: Array[1]...\r\nok: false\r\nstart_time: Tue Dec 08 2015 20:14:09 GMT+0200 (SAST)\r\nstatus: \"aborting\"\r\nstatus: 50\r\n```\r\nfollowed by a warning \r\n```\r\nPouchDB: the remote database may not have CORS enabled.If not please enable CORS: http://pouchdb.com/errors.html#no_access_control_allow_origin_header\r\n```\r\n\r\nbut I definitely have cors enabled \r\n\r\n```\r\ncurl --user XXX:XXX xxxx.cloudant.com/_api/v2/user/config/cors \r\n{\r\n  \"enable_cors\": true, \r\n  \"allow_credentials\": true, \r\n  \"origins\": [\r\n    \"*\"\r\n  ]\r\n}\r\n```\r\n\r\nthis happens periodically, but especially when offline. I am canceling the sync as follows when offline is detected:\r\n\r\n```\r\n// on startup / online detected:\r\nsync.company = db.sync(companyUrl, {live: true, retry: true})...\r\n\r\n// if offline detected\r\nconsole.log('offline detected - stopping sync');\r\nif (sync.company) sync.company.cancel();\r\n```\r\n\r\nbut am also seeing this error\r\n```\r\noffline detected - stopping sync\r\nTypeError: o.company.cancel is not a function\r\n    at e (vendor.js:62)\r\n    at Object.fn (vendor.js:62)\r\n    at n.$digest (vendor.js:5)\r\n    at n.$apply (vendor.js:5)\r\n````\r\n(code has been minified)\r\n\r\ninspecting the `sync.company` object i see it is a promise.... but the docs show that you should be able to call cancel() ??\r\n\r\nhttp://pouchdb.com/api.html#sync\r\n\r\n\r\nnot sure if the sync cancel is in any way related to the 500 error, but thought it would be worth mentioning\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pouchdb/pouchdb/issues/comments/164209179","html_url":"https://github.com/pouchdb/pouchdb/issues/4643#issuecomment-164209179","issue_url":"https://api.github.com/repos/pouchdb/pouchdb/issues/4643","id":164209179,"user":{"login":"nolanlawson","id":283842,"avatar_url":"https://avatars.githubusercontent.com/u/283842?v=3","gravatar_id":"","url":"https://api.github.com/users/nolanlawson","html_url":"https://github.com/nolanlawson","followers_url":"https://api.github.com/users/nolanlawson/followers","following_url":"https://api.github.com/users/nolanlawson/following{/other_user}","gists_url":"https://api.github.com/users/nolanlawson/gists{/gist_id}","starred_url":"https://api.github.com/users/nolanlawson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nolanlawson/subscriptions","organizations_url":"https://api.github.com/users/nolanlawson/orgs","repos_url":"https://api.github.com/users/nolanlawson/repos","events_url":"https://api.github.com/users/nolanlawson/events{/privacy}","received_events_url":"https://api.github.com/users/nolanlawson/received_events","type":"User","site_admin":false},"created_at":"2015-12-13T01:34:36Z","updated_at":"2015-12-13T01:34:36Z","body":"Does this only occur with Cloudant? Which browser does it occur in?\r\n\r\nAlso please please please post screenshots of the Network panel containing the original error, because the \"CustomPouchError - 500 - Database encountered an unknown error\" gives us zero information."}}