question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Facing DatabaseError [SequelizeDatabaseError]: SQLITE_ERROR: no such table: Wallets , while doing npm start after npm install. Also tried changing access rights but got similar error.[🐛]

See original GitHub issue

C:\Users\Dheeraj Verma\Development_Projects\Node_Projects\juice-shop\node_modules\sequelize\lib\dialects\sqlite\query.js:403 return new sequelizeErrors.DatabaseError(err); ^

DatabaseError [SequelizeDatabaseError]: SQLITE_ERROR: no such table: Wallets at Query.formatError (C:\Users\Dheeraj Verma\Development_Projects\Node_Projects\juice-shop\node_modules\sequelize\lib\dialects\sqlite\query.js:403:16) at Query._handleQueryResponse (C:\Users\Dheeraj Verma\Development_Projects\Node_Projects\juice-shop\node_modules\sequelize\lib\dialects\sqlite\query.js:72:18) at afterExecute (C:\Users\Dheeraj Verma\Development_Projects\Node_Projects\juice-shop\node_modules\sequelize\lib\dialects\sqlite\query.js:238:27) at Statement.errBack (C:\Users\Dheeraj Verma\Development_Projects\Node_Projects\juice-shop\node_modules\sqlite3\lib\sqlite3.js:14:21) { parent: [Error: SQLITE_ERROR: no such table: Wallets] { errno: 1, code: ‘SQLITE_ERROR’, sql: ‘SELECT sum(balance) AS sum FROM Wallets AS Wallet;’ }, original: [Error: SQLITE_ERROR: no such table: Wallets] { errno: 1, code: ‘SQLITE_ERROR’, sql: ‘SELECT sum(balance) AS sum FROM Wallets AS Wallet;’ }, SQLITE_Error_juice-shop

sql: ‘SELECT sum(balance) AS sum FROM Wallets AS Wallet;’, parameters: undefined }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
matt-mosescommented, Sep 20, 2022

Haha. No offensive taken! 😃

I’ve been looking at this all day and I believe the race condition is between the initial database sequelize.sync() and the metrics loop instantiation. Delaying the metric loops instantiation is working for me. Previously, it looks like the metric loop was getting instantiated during module import which was then causing it to race with the startup code which does the sequelize.sync(). Not ready to submit this as a PR but would love some feedback and would be happy to continue working on this.

image

Here are logs from when this race happens. These happen right after an npm start. You can see the existing tables all get dropped and begin to get re-created on startup. During that process you can also see the metrics loop start up and the loop is often looking for the Wallet table but sometimes it is other tables depending on what point sequelize.sync() has been able to proceed.

└─$ npm start

> juice-shop@14.2.1 start
> node build/app

info: All dependencies in ./package.json are satisfied (OK)
info: Chatbot training data botDefaultTrainingData.json validated (OK)
info: Detected Node.js version v16.17.0 (OK)
info: Detected OS linux (OK)
info: Detected CPU x64 (OK)
info: Configuration default validated (OK)
info: Entity models 19 of 19 are initialized (OK)
info: Required file server.js is present (OK)
info: Required file index.html is present (OK)
info: Required file styles.css is present (OK)
info: Required file main.js is present (OK)
info: Required file tutorial.js is present (OK)
info: Required file polyfills.js is present (OK)
info: Required file runtime.js is present (OK)
info: Required file vendor.js is present (OK)
Executing (default): DROP TABLE IF EXISTS `Wallets`;
info: Port 3000 is available (OK)
(node:501271) [DEP0152] DeprecationWarning: Custom PerformanceEntry accessors are deprecated. Please use the detail property.
(Use `node --trace-deprecation ...` to show where the warning was created)
Executing (default): DROP TABLE IF EXISTS `SecurityAnswers`;
Executing (default): DROP TABLE IF EXISTS `SecurityQuestions`;
Executing (default): DROP TABLE IF EXISTS `Recycles`;
Executing (default): DROP TABLE IF EXISTS `Quantities`;
Executing (default): DROP TABLE IF EXISTS `PrivacyRequests`;
Executing (default): DROP TABLE IF EXISTS `Memories`;
Executing (default): DROP TABLE IF EXISTS `ImageCaptchas`;
Executing (default): DROP TABLE IF EXISTS `Feedbacks`;
Executing (default): DROP TABLE IF EXISTS `Deliveries`;
Executing (default): DROP TABLE IF EXISTS `Complaints`;
Executing (default): DROP TABLE IF EXISTS `Challenges`;
Executing (default): DROP TABLE IF EXISTS `Cards`;
Executing (default): DROP TABLE IF EXISTS `Captchas`;
Executing (default): DROP TABLE IF EXISTS `BasketItems`;
Executing (default): DROP TABLE IF EXISTS `Products`;
Executing (default): DROP TABLE IF EXISTS `Baskets`;
Executing (default): DROP TABLE IF EXISTS `Addresses`;
Executing (default): DROP TABLE IF EXISTS `Users`;
Executing (default): PRAGMA foreign_keys = OFF
Executing (default): DROP TABLE IF EXISTS `Addresses`;
Executing (default): DROP TABLE IF EXISTS `Baskets`;
Executing (default): DROP TABLE IF EXISTS `BasketItems`;
Executing (default): DROP TABLE IF EXISTS `Captchas`;
Executing (default): DROP TABLE IF EXISTS `Cards`;
Executing (default): DROP TABLE IF EXISTS `Challenges`;
Executing (default): DROP TABLE IF EXISTS `Complaints`;
Executing (default): DROP TABLE IF EXISTS `Deliveries`;
Executing (default): DROP TABLE IF EXISTS `Feedbacks`;
Executing (default): DROP TABLE IF EXISTS `ImageCaptchas`;
Executing (default): DROP TABLE IF EXISTS `Memories`;
Executing (default): DROP TABLE IF EXISTS `PrivacyRequests`;
Executing (default): DROP TABLE IF EXISTS `Products`;
Executing (default): DROP TABLE IF EXISTS `Quantities`;
Executing (default): DROP TABLE IF EXISTS `Recycles`;
Executing (default): DROP TABLE IF EXISTS `SecurityAnswers`;
Executing (default): DROP TABLE IF EXISTS `SecurityQuestions`;
Executing (default): DROP TABLE IF EXISTS `Users`;
Executing (default): DROP TABLE IF EXISTS `Wallets`;
Executing (default): PRAGMA foreign_keys = ON
Executing (default): DROP TABLE IF EXISTS `Users`;
Executing (default): CREATE TABLE IF NOT EXISTS `Users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `username` VARCHAR(255) DEFAULT '', `email` VARCHAR(255) UNIQUE, `password` VARCHAR(255), `role` VARCHAR(255) DEFAULT 'customer', `deluxeToken` VARCHAR(255) DEFAULT '', `lastLoginIp` VARCHAR(255) DEFAULT '0.0.0.0', `profileImage` VARCHAR(255) DEFAULT '/assets/public/images/uploads/default.svg', `totpSecret` VARCHAR(255) DEFAULT '', `isActive` TINYINT(1) DEFAULT 1, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `deletedAt` DATETIME);
Executing (default): PRAGMA INDEX_LIST(`Users`)
Executing (default): PRAGMA INDEX_INFO(`sqlite_autoindex_Users_1`)
Executing (default): DROP TABLE IF EXISTS `Addresses`;
Executing (default): CREATE TABLE IF NOT EXISTS `Addresses` (`UserId` INTEGER REFERENCES `Users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, `id` INTEGER PRIMARY KEY AUTOINCREMENT, `fullName` VARCHAR(255), `mobileNum` INTEGER, `zipCode` VARCHAR(255), `streetAddress` VARCHAR(255), `city` VARCHAR(255), `state` VARCHAR(255), `country` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Addresses`)
Executing (default): DROP TABLE IF EXISTS `Baskets`;
Executing (default): CREATE TABLE IF NOT EXISTS `Baskets` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `coupon` VARCHAR(255), `UserId` INTEGER REFERENCES `Users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Baskets`)
Executing (default): DROP TABLE IF EXISTS `Products`;
Executing (default): CREATE TABLE IF NOT EXISTS `Products` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `description` VARCHAR(255), `price` DECIMAL, `deluxePrice` DECIMAL, `image` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `deletedAt` DATETIME);
Executing (default): PRAGMA INDEX_LIST(`Products`)
Executing (default): DROP TABLE IF EXISTS `BasketItems`;
Executing (default): CREATE TABLE IF NOT EXISTS `BasketItems` (`ProductId` INTEGER REFERENCES `Products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, `BasketId` INTEGER REFERENCES `Baskets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, `id` INTEGER PRIMARY KEY AUTOINCREMENT, `quantity` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, UNIQUE (`ProductId`, `BasketId`));
Executing (default): PRAGMA INDEX_LIST(`BasketItems`)
Executing (default): PRAGMA INDEX_INFO(`sqlite_autoindex_BasketItems_1`)
Executing (default): DROP TABLE IF EXISTS `Captchas`;
Executing (default): CREATE TABLE IF NOT EXISTS `Captchas` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `captchaId` INTEGER, `captcha` VARCHAR(255), `answer` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Captchas`)
Executing (default): DROP TABLE IF EXISTS `Cards`;
Executing (default): CREATE TABLE IF NOT EXISTS `Cards` (`UserId` INTEGER REFERENCES `Users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, `id` INTEGER PRIMARY KEY AUTOINCREMENT, `fullName` VARCHAR(255), `cardNum` INTEGER, `expMonth` INTEGER, `expYear` INTEGER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Cards`)
Executing (default): DROP TABLE IF EXISTS `Challenges`;
Executing (default): CREATE TABLE IF NOT EXISTS `Challenges` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `key` VARCHAR(255), `name` VARCHAR(255), `category` VARCHAR(255), `tags` VARCHAR(255), `description` VARCHAR(255), `difficulty` INTEGER, `hint` VARCHAR(255), `hintUrl` VARCHAR(255), `mitigationUrl` VARCHAR(255), `solved` TINYINT(1), `disabledEnv` VARCHAR(255), `tutorialOrder` NUMBER, `codingChallengeStatus` NUMBER, `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Challenges`)
Executing (default): DROP TABLE IF EXISTS `Complaints`;
Executing (default): CREATE TABLE IF NOT EXISTS `Complaints` (`UserId` INTEGER REFERENCES `Users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE, `id` INTEGER PRIMARY KEY AUTOINCREMENT, `message` VARCHAR(255), `file` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Complaints`)
Executing (default): DROP TABLE IF EXISTS `Deliveries`;
Executing (default): CREATE TABLE IF NOT EXISTS `Deliveries` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` VARCHAR(255), `price` FLOAT, `deluxePrice` FLOAT, `eta` FLOAT, `icon` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): SELECT sum(`balance`) AS `sum` FROM `Wallets` AS `Wallet`;
Executing (default): SELECT count(*) AS `count` FROM `Users` AS `User` WHERE (`User`.`deletedAt` IS NULL AND `User`.`role` = 'customer');
Executing (default): SELECT count(*) AS `count` FROM `Users` AS `User` WHERE (`User`.`deletedAt` IS NULL AND `User`.`role` = 'deluxe');
Executing (default): SELECT count(*) AS `count` FROM `Users` AS `User` WHERE (`User`.`deletedAt` IS NULL);
Executing (default): SELECT count(*) AS `count` FROM `Feedbacks` AS `Feedback`;
Executing (default): SELECT count(*) AS `count` FROM `Complaints` AS `Complaint`;
Executing (default): SELECT count(*) AS `count` FROM `Challenges` AS `Challenge` WHERE `Challenge`.`codingChallengeStatus` = 1;
Executing (default): SELECT count(*) AS `count` FROM `Challenges` AS `Challenge` WHERE `Challenge`.`codingChallengeStatus` = 2;
Executing (default): SELECT count(*) AS `count` FROM `Challenges` AS `Challenge` WHERE `Challenge`.`codingChallengeStatus` != 0;
Executing (default): PRAGMA INDEX_LIST(`Deliveries`)
Executing (default): DROP TABLE IF EXISTS `Feedbacks`;
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error
    at Database.<anonymous> (/u/juice-shop1/node_modules/sequelize/lib/dialects/sqlite/query.js:179:27)
    at /u/juice-shop1/node_modules/sequelize/lib/dialects/sqlite/query.js:177:50
    at new Promise (<anonymous>)
    at Query.run (/u/juice-shop1/node_modules/sequelize/lib/dialects/sqlite/query.js:177:12)
    at /u/juice-shop1/node_modules/sequelize/lib/sequelize.js:314:28
    at async SQLiteQueryInterface.rawSelect (/u/juice-shop1/node_modules/sequelize/lib/dialects/abstract/query-interface.js:434:18)
    at async Function.aggregate (/u/juice-shop1/node_modules/sequelize/lib/model.js:1265:19)
    at async Function.sum (/u/juice-shop1/node_modules/sequelize/lib/model.js:1320:12) {
  name: 'SequelizeDatabaseError',
  parent: [Error: SQLITE_ERROR: no such table: Wallets] {
    errno: 1,
    code: 'SQLITE_ERROR',
    sql: 'SELECT sum(`balance`) AS `sum` FROM `Wallets` AS `Wallet`;'
  },
  original: [Error: SQLITE_ERROR: no such table: Wallets] {
    errno: 1,
    code: 'SQLITE_ERROR',
    sql: 'SELECT sum(`balance`) AS `sum` FROM `Wallets` AS `Wallet`;'
  },
  sql: 'SELECT sum(`balance`) AS `sum` FROM `Wallets` AS `Wallet`;',
  parameters: {}
}

0reactions
bkimminichcommented, Sep 20, 2022

This looks very promising! My last attempt was waiting for the entity creation, but it seems that didn’t even trigger the DB reset… 😅 … info: Entity models 19 of 19 are initialized was supposed to be where the DB is ready… 😀

Read more comments on GitHub >

github_iconTop Results From Across the Web

SequelizeDatabaseError: SQLITE_ERROR: no such table
its probably late to answer but i just found solution. this problem occurred to me because I have made changes to database.
Read more >
bkimminich/juice-shop - Gitter
when i do npm start the console show this message: (node:5514) ... Unhandled rejection SequelizeDatabaseError: SQLITE_ERROR: no such table: Wallets
Read more >
Troubleshooting - Pwning OWASP Juice Shop
If npm install on Linux runs into WARN cannot run in wd problems (e.g. during the frontend installation step) try running npm install...
Read more >
How to fix: npm ERR! enoent ENOENT: no such file or ...
Finally, I found a solution and a reason for that issue. The error occurred when I was trying to install @testing-library/react npm package....
Read more >
SQLITE_ERROR: no such table - SAP Community
Hi, in an attempt to learn about the authentication and authorisation in CAP apps on Cloud Foundry I have been using this documentation ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found