[Bug]: Scan fails to add new books #2541

Closed
opened 2026-04-25 00:08:10 +02:00 by adam · 9 comments
Owner

Originally created by @soldierj on GitHub (Feb 3, 2025).

What happened?

Just updated to 2.19.0, scan fails to add new audiobooks.

What did you expect to happen?

I have about 50 new audiobooks to add.

Steps to reproduce the issue

  1. I have used .audiobookshelf file to bring back all books. I have about 25 backups in time.

Audiobookshelf version

2.19.0

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Other (list in "Additional Notes" box)

If the issue is being seen in the UI, what browsers are you seeing the problem on?

None

Logs

Crash log:  {"timestamp":"2025-02-03 14:56:25.509","source":"Server.js:219","message":"[Server] Unhandled rejection: Error: ConnectionManager.getConnection was called after the connection manager was closed!\n    at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n    at /node_modules/sequelize/lib/sequelize.js:305:111\n    at /node_modules/retry-as-promised/dist/index.js:59:25\n    at new Promise (<anonymous>)\n    at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n    at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n    at SQLiteQueryInterface.select (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:407:33)\n    at library.findAll (/node_modules/sequelize/lib/model.js:1140:47)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async library.findOne (/node_modules/sequelize/lib/model.js:1240:12) \npromise: Promise {\n  <rejected> Error: ConnectionManager.getConnection was called after the connection manager was closed!\n      at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n      at /node_modules/sequelize/lib/sequelize.js:305:111\n      at /node_modules/retry-as-promised/dist/index.js:59:25\n      at new Promise (<anonymous>)\n      at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n      at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n      at SQLiteQueryInterface.select (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:407:33)\n      at library.findAll (/node_modules/sequelize/lib/model.js:1140:47)\n      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n      at async library.findOne (/node_modules/sequelize/lib/model.js:1240:12)\n}","levelName":"FATAL","level":5}
{"timestamp":"2025-02-03 19:08:49.622","source":"Server.js:219","message":"[Server] Unhandled rejection: Error: ConnectionManager.getConnection was called after the connection manager was closed!\n    at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n    at /node_modules/sequelize/lib/sequelize.js:305:111\n    at /node_modules/retry-as-promised/dist/index.js:59:25\n    at new Promise (<anonymous>)\n    at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n    at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n    at SQLiteQueryInterface.upsert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:341:33)\n    at setting.upsert (/node_modules/sequelize/lib/model.js:1533:46)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ApiRouter.updateServerSettings (/server/controllers/MiscController.js:136:7) \npromise: Promise {\n  <rejected> Error: ConnectionManager.getConnection was called after the connection manager was closed!\n      at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n      at /node_modules/sequelize/lib/sequelize.js:305:111\n      at /node_modules/retry-as-promised/dist/index.js:59:25\n      at new Promise (<anonymous>)\n      at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n      at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n      at SQLiteQueryInterface.upsert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:341:33)\n      at setting.upsert (/node_modules/sequelize/lib/model.js:1533:46)\n      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n      at async ApiRouter.updateServerSettings (/server/controllers/MiscController.js:136:7)\n}","levelName":"FATAL","level":5}

What I have found in the daily log file. 

{"timestamp":"2025-02-03 19:12:54.643","source":"LibraryScanner.js:119","message":"[LibraryScanner] Library scan 434acfec-a562-4c28-9d42-65a4f9495be2 failed after 2:05 | 0 Added | 20 Updated | 0 Missing. TypeError: this.buffer.charCodeAt is not a function\n    at Tokenizer.parse (/node_modules/htmlparser2/lib/Tokenizer.js:741:33)\n    at Tokenizer.write (/node_modules/htmlparser2/lib/Tokenizer.js:158:14)\n    at Parser.write (/node_modules/htmlparser2/lib/Parser.js:459:28)\n    at sanitizeHtml (/server/libs/sanitizeHtml/index.js:614:10)\n    at Object.stripAllTags (/server/utils/htmlSanitizer.js:35:19)\n    at Book.oldMetadataToJSONExpanded (/server/models/Book.js:583:73)\n    at Book.toOldJSONExpanded (/server/models/Book.js:653:22)\n    at LibraryItem.toOldJSONExpanded (/server/models/LibraryItem.js:971:25)\n    at /server/scanner/LibraryScanner.js:229:46\n    at Array.map (<anonymous>)","levelName":"ERROR","level":4}

Additional Notes

synology

Originally created by @soldierj on GitHub (Feb 3, 2025). ### What happened? Just updated to 2.19.0, scan fails to add new audiobooks. ### What did you expect to happen? I have about 50 new audiobooks to add. ### Steps to reproduce the issue 1. I have used .audiobookshelf file to bring back all books. I have about 25 backups in time. ### Audiobookshelf version 2.19.0 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Other (list in "Additional Notes" box) ### If the issue is being seen in the UI, what browsers are you seeing the problem on? None ### Logs ```shell Crash log: {"timestamp":"2025-02-03 14:56:25.509","source":"Server.js:219","message":"[Server] Unhandled rejection: Error: ConnectionManager.getConnection was called after the connection manager was closed!\n at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n at /node_modules/sequelize/lib/sequelize.js:305:111\n at /node_modules/retry-as-promised/dist/index.js:59:25\n at new Promise (<anonymous>)\n at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n at SQLiteQueryInterface.select (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:407:33)\n at library.findAll (/node_modules/sequelize/lib/model.js:1140:47)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async library.findOne (/node_modules/sequelize/lib/model.js:1240:12) \npromise: Promise {\n <rejected> Error: ConnectionManager.getConnection was called after the connection manager was closed!\n at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n at /node_modules/sequelize/lib/sequelize.js:305:111\n at /node_modules/retry-as-promised/dist/index.js:59:25\n at new Promise (<anonymous>)\n at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n at SQLiteQueryInterface.select (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:407:33)\n at library.findAll (/node_modules/sequelize/lib/model.js:1140:47)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async library.findOne (/node_modules/sequelize/lib/model.js:1240:12)\n}","levelName":"FATAL","level":5} {"timestamp":"2025-02-03 19:08:49.622","source":"Server.js:219","message":"[Server] Unhandled rejection: Error: ConnectionManager.getConnection was called after the connection manager was closed!\n at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n at /node_modules/sequelize/lib/sequelize.js:305:111\n at /node_modules/retry-as-promised/dist/index.js:59:25\n at new Promise (<anonymous>)\n at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n at SQLiteQueryInterface.upsert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:341:33)\n at setting.upsert (/node_modules/sequelize/lib/model.js:1533:46)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async ApiRouter.updateServerSettings (/server/controllers/MiscController.js:136:7) \npromise: Promise {\n <rejected> Error: ConnectionManager.getConnection was called after the connection manager was closed!\n at ConnectionManager.getConnection (/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:70:13)\n at /node_modules/sequelize/lib/sequelize.js:305:111\n at /node_modules/retry-as-promised/dist/index.js:59:25\n at new Promise (<anonymous>)\n at retryAsPromised (/node_modules/retry-as-promised/dist/index.js:48:12)\n at Sequelize.query (/node_modules/sequelize/lib/sequelize.js:300:12)\n at SQLiteQueryInterface.upsert (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:341:33)\n at setting.upsert (/node_modules/sequelize/lib/model.js:1533:46)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async ApiRouter.updateServerSettings (/server/controllers/MiscController.js:136:7)\n}","levelName":"FATAL","level":5} What I have found in the daily log file. {"timestamp":"2025-02-03 19:12:54.643","source":"LibraryScanner.js:119","message":"[LibraryScanner] Library scan 434acfec-a562-4c28-9d42-65a4f9495be2 failed after 2:05 | 0 Added | 20 Updated | 0 Missing. TypeError: this.buffer.charCodeAt is not a function\n at Tokenizer.parse (/node_modules/htmlparser2/lib/Tokenizer.js:741:33)\n at Tokenizer.write (/node_modules/htmlparser2/lib/Tokenizer.js:158:14)\n at Parser.write (/node_modules/htmlparser2/lib/Parser.js:459:28)\n at sanitizeHtml (/server/libs/sanitizeHtml/index.js:614:10)\n at Object.stripAllTags (/server/utils/htmlSanitizer.js:35:19)\n at Book.oldMetadataToJSONExpanded (/server/models/Book.js:583:73)\n at Book.toOldJSONExpanded (/server/models/Book.js:653:22)\n at LibraryItem.toOldJSONExpanded (/server/models/LibraryItem.js:971:25)\n at /server/scanner/LibraryScanner.js:229:46\n at Array.map (<anonymous>)","levelName":"ERROR","level":4} ``` ### Additional Notes synology
adam added the bug label 2026-04-25 00:08:10 +02:00
adam closed this issue 2026-04-25 00:08:10 +02:00
Author
Owner

@soldierj commented on GitHub (Feb 5, 2025):

I am still baffled trying to bring back my backups and all have failed

@soldierj commented on GitHub (Feb 5, 2025): I am still baffled trying to bring back my backups and all have failed
Author
Owner

@nichwall commented on GitHub (Feb 5, 2025):

Can you provide one of your backups? If it's too big to email a link to download it also works. I probably won't be able to look at it until Thursday, but that will probably be more helpful that just guessing what is wrong with it.

@nichwall commented on GitHub (Feb 5, 2025): Can you provide one of your backups? If it's too big to email a link to download it also works. I probably won't be able to look at it until Thursday, but that will probably be more helpful that just guessing what is wrong with it.
Author
Owner

@soldierj commented on GitHub (Feb 5, 2025):

Sure stand by.

This file is about 2.2gb, sry bout that, got about 25k books in all
I also have many backups if this isn't working, all of them are giving me the same symptom.

Thanks, Jim

@soldierj commented on GitHub (Feb 5, 2025): Sure stand by. This file is about 2.2gb, sry bout that, got about 25k books in all I also have many backups if this isn't working, all of them are giving me the same symptom. Thanks, Jim
Author
Owner

@nichwall commented on GitHub (Feb 5, 2025):

Thanks, I have downloaded the file if you want to remove it from public download.

@nichwall commented on GitHub (Feb 5, 2025): Thanks, I have downloaded the file if you want to remove it from public download.
Author
Owner

@nichwall commented on GitHub (Feb 5, 2025):

I have not really been able to dig into this much, but have you used other tools to edit the database? I see several views and extra tables in your database. For example, there is an extra sqlite_stat1 and sqlite_stat4 table. Several views are saved as shown in the following picture as well.

These extra tables and stored views shouldn't be causing an issue, but I am curious if editing the database with another tool has caused an issue.

Image

@nichwall commented on GitHub (Feb 5, 2025): I have not really been able to dig into this much, but have you used other tools to edit the database? I see several views and extra tables in your database. For example, there is an extra `sqlite_stat1` and `sqlite_stat4` table. Several views are saved as shown in the following picture as well. These extra tables and stored views shouldn't be causing an issue, but I am curious if editing the database with another tool has caused an issue. ![Image](https://github.com/user-attachments/assets/21fceb3e-0c6e-47e0-a6d6-71a9a5632161)
Author
Owner

@soldierj commented on GitHub (Feb 5, 2025):

yes, to find inconsistencies/duplicates that I have created. If you look at authors, I've edited them too. Its never been a problem that I am aware of. I do keep many backups of the .absdatabase.sqlite separately, if that helps. My degree is database admin and like to work with SQL though I feel like a rookie at it sometimes.

@soldierj commented on GitHub (Feb 5, 2025): yes, to find inconsistencies/duplicates that I have created. If you look at authors, I've edited them too. Its never been a problem that I am aware of. I do keep many backups of the .absdatabase.sqlite separately, if that helps. My degree is database admin and like to work with SQL though I feel like a rookie at it sometimes.
Author
Owner

@soldierj commented on GitHub (Feb 9, 2025):

Image

Image

I got it! I deleted out the queries (views) from the db and just ran scans... Many... hope it stays good now

@soldierj commented on GitHub (Feb 9, 2025): ![Image](https://github.com/user-attachments/assets/b9e7f05c-dd4b-4a08-9b6d-1f4076d452ec) ![Image](https://github.com/user-attachments/assets/cc6736e0-74ec-4216-ac1e-8aa2178e8d89) I got it! I deleted out the queries (views) from the db and just ran scans... Many... hope it stays good now
Author
Owner

@soldierj commented on GitHub (Feb 9, 2025):

You can close this ticket. Thanks

@soldierj commented on GitHub (Feb 9, 2025): You can close this ticket. Thanks
Author
Owner

@nichwall commented on GitHub (Feb 9, 2025):

Glad you got it figured out! Not sure why the scans would be affected by those extra views.

@nichwall commented on GitHub (Feb 9, 2025): Glad you got it figured out! Not sure why the scans would be affected by those extra views.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2541