{"action":"created","issue":{"url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/14","repository_url":"https://api.github.com/repos/kriasoft/node-sqlite","labels_url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/14/comments","events_url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/14/events","html_url":"https://github.com/kriasoft/node-sqlite/issues/14","id":179533661,"number":14,"title":"SQLITE_ERROR not being rejected?","user":{"login":"TenaciousDEK","id":20978835,"avatar_url":"https://avatars.githubusercontent.com/u/20978835?v=3","gravatar_id":"","url":"https://api.github.com/users/TenaciousDEK","html_url":"https://github.com/TenaciousDEK","followers_url":"https://api.github.com/users/TenaciousDEK/followers","following_url":"https://api.github.com/users/TenaciousDEK/following{/other_user}","gists_url":"https://api.github.com/users/TenaciousDEK/gists{/gist_id}","starred_url":"https://api.github.com/users/TenaciousDEK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TenaciousDEK/subscriptions","organizations_url":"https://api.github.com/users/TenaciousDEK/orgs","repos_url":"https://api.github.com/users/TenaciousDEK/repos","events_url":"https://api.github.com/users/TenaciousDEK/events{/privacy}","received_events_url":"https://api.github.com/users/TenaciousDEK/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-09-27T15:50:34Z","updated_at":"2016-12-19T18:51:51Z","closed_at":null,"body":"Hi,\nI'm wondering if this is a bug with either node-sql or possibly the underlying node-sqlite3 perhaps?\n\nIn experimenting with transactions on multiple connections I ran the following test in mocha, which appears to pass with no errors. I'm basically creating two database connections but trying to begin successive transactions on just one of them, in order to force an error (which is why I'm using db1 twice rather than db2). Worryingly, the code below appears to pass with no errors shown!\n\nSqlite naturally balks at this and if you were to trap the error on 'transactDatabases' on the Promise.all with a .catch, it would correctly show the following error:-\n\n`{ Error: SQLITE_ERROR: cannot start a transaction within a transaction\n    at Error (native) errno: 1, code: 'SQLITE_ERROR' }`\n\nThe issue is though that I can't seem to trap this error in mocha as the Promise.all() doesn't appear to be rejected. It should be sufficient in mocha for me to return the rejected transactDatabases promise I would have thought?\n\nIs this an error coming from Sqlite that's not being caught by the javascript libraries? Or more likely, as I'm just starting out in Javascript, am I doing something very wrong here?\n\nThe full test code is shown below...\n\n```\nimport sqlite from 'sqlite';\n\ndescribe('Sqlite', () => {\n  describe('Can instantiate multiple database connections', () => {\n    it.only('Can handle multiple isolated transactions', () => {\n      const openDatabases = Promise.resolve()\n      .then(() => Promise.all([\n        sqlite.open(':memory:', { Promise }),\n        sqlite.open(':memory:', { Promise }),\n      ]));\n\n      const transactDatabases = openDatabases\n      .then(([db1, db2]) => {\n        Promise.all([\n          db1.run('BEGIN IMMEDIATE TRANSACTION'),\n          db1.run('BEGIN IMMEDIATE TRANSACTION'),\n        ]);\n      });\n      return transactDatabases;\n    });\n  });\n});\n```\n\nThanks!\n\nDerek\n"},"comment":{"url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/comments/268045785","html_url":"https://github.com/kriasoft/node-sqlite/issues/14#issuecomment-268045785","issue_url":"https://api.github.com/repos/kriasoft/node-sqlite/issues/14","id":268045785,"user":{"login":"claudiopro","id":860099,"avatar_url":"https://avatars.githubusercontent.com/u/860099?v=3","gravatar_id":"","url":"https://api.github.com/users/claudiopro","html_url":"https://github.com/claudiopro","followers_url":"https://api.github.com/users/claudiopro/followers","following_url":"https://api.github.com/users/claudiopro/following{/other_user}","gists_url":"https://api.github.com/users/claudiopro/gists{/gist_id}","starred_url":"https://api.github.com/users/claudiopro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claudiopro/subscriptions","organizations_url":"https://api.github.com/users/claudiopro/orgs","repos_url":"https://api.github.com/users/claudiopro/repos","events_url":"https://api.github.com/users/claudiopro/events{/privacy}","received_events_url":"https://api.github.com/users/claudiopro/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T18:51:51Z","updated_at":"2016-12-19T18:51:51Z","body":"I second @dmm's concerns and started seeing similar issues when handling `SQLITE_BUSY` errors in adelia:\r\n\r\nhttps://travis-ci.org/emeraldion/adelia/jobs/185238161#L542 (Node 6.9)\r\n\r\n```\r\n(node:1686) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: SQLITE_BUSY: database is locked\r\n```\r\n\r\nhttps://travis-ci.org/emeraldion/adelia/jobs/185238159#L540 (Node 7.2)\r\n\r\n```\r\n(node:1686) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: SQLITE_BUSY: database is locked\r\n(node:1686) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\r\n```\r\n\r\nI'm more than happy to look into this :smile:"}}
{"actor":{"display_login":"claudiopro"}}