[Bug]: Server Crash when I try to delete a library #2368

Closed
opened 2026-04-25 00:06:33 +02:00 by adam · 7 comments
Owner

Originally created by @JBlond on GitHub (Nov 21, 2024).

What happened?

The server crashes when I try to delete a library

What did you expect to happen?

The library being deleted

Steps to reproduce the issue

  1. Choose a library
  2. Click on delete

Audiobookshelf version

v2.17.1

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

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

Chrome

Logs

audiobookshelf  | Config /config /metadata
audiobookshelf  | [2024-11-21 16:26:40.871] INFO: === Starting Server ===
audiobookshelf  | [2024-11-21 16:26:40.880] INFO: [Server] Init v2.17.1
audiobookshelf  | [2024-11-21 16:26:40.881] INFO: [Server] Node.js Version: v20.18.0
audiobookshelf  | [2024-11-21 16:26:40.881] INFO: [Server] Platform: linux
audiobookshelf  | [2024-11-21 16:26:40.882] INFO: [Server] Arch: x64
audiobookshelf  | [2024-11-21 16:26:40.893] INFO: [Database] Initializing db at "/config/absdatabase.sqlite"
audiobookshelf  | [2024-11-21 16:26:40.931] INFO: [Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so
audiobookshelf  | [2024-11-21 16:26:40.932] INFO: [Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so
audiobookshelf  | [2024-11-21 16:26:40.932] INFO: [Database] Db supports unaccent and unicode foldings
audiobookshelf  | [2024-11-21 16:26:40.933] INFO: [Database] Db connection was successful
audiobookshelf  | [2024-11-21 16:26:40.957] INFO: [MigrationManager] Database is already up to date.
audiobookshelf  | [2024-11-21 16:26:41.248] INFO: [Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpiso
de, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackS
ession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare
audiobookshelf  | [2024-11-21 16:26:55.566] FATAL: [Server] Unhandled rejection: Error
audiobookshelf  |     at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27)
audiobookshelf  |     at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50
audiobookshelf  |     at new Promise (<anonymous>)
audiobookshelf  |     at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12)
audiobookshelf  |     at /node_modules/sequelize/lib/sequelize.js:315:28
audiobookshelf  |     at async SQLiteQueryInterface.bulkDelete (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:403:12)
audiobookshelf  |     at async library.destroy (/node_modules/sequelize/lib/model.js:1838:16)
audiobookshelf  |     at async ApiRouter.delete (/server/controllers/LibraryController.js:508:5) {
audiobookshelf  |   name: 'SequelizeForeignKeyConstraintError',
audiobookshelf  |   parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |     errno: 19,
audiobookshelf  |     code: 'SQLITE_CONSTRAINT',
audiobookshelf  |     sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'"
audiobookshelf  |   },
audiobookshelf  |   original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |     errno: 19,
audiobookshelf  |     code: 'SQLITE_CONSTRAINT',
audiobookshelf  |     sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'"
audiobookshelf  |   },
audiobookshelf  |   sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'",
audiobookshelf  |   parameters: {},
audiobookshelf  |   table: undefined,
audiobookshelf  |   fields: undefined,
audiobookshelf  |   value: undefined,
audiobookshelf  |   index: undefined,
audiobookshelf  |   reltype: undefined
audiobookshelf  | }
audiobookshelf  | promise: Promise {
audiobookshelf  |   <rejected> Error
audiobookshelf  |       at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27)
audiobookshelf  |       at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50
audiobookshelf  |       at new Promise (<anonymous>)
audiobookshelf  |       at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12)
audiobookshelf  |       at /node_modules/sequelize/lib/sequelize.js:315:28
audiobookshelf  |       at async SQLiteQueryInterface.bulkDelete (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:403:12)
audiobookshelf  |       at async library.destroy (/node_modules/sequelize/lib/model.js:1838:16)
audiobookshelf  |       at async ApiRouter.delete (/server/controllers/LibraryController.js:508:5) {
audiobookshelf  |     name: 'SequelizeForeignKeyConstraintError',
audiobookshelf  |     parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |       errno: 19,
audiobookshelf  |       code: 'SQLITE_CONSTRAINT',
audiobookshelf  |       sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'"
audiobookshelf  |     },
audiobookshelf  |     original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
audiobookshelf  |       errno: 19,
audiobookshelf  |       code: 'SQLITE_CONSTRAINT',
audiobookshelf  |       sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'"
audiobookshelf  |     },
audiobookshelf  |     sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'",
audiobookshelf  |     parameters: {},
audiobookshelf  |     table: undefined,
audiobookshelf  |     fields: undefined,
audiobookshelf  |     value: undefined,
audiobookshelf  |     index: undefined,
audiobookshelf  |     reltype: undefined
audiobookshelf  |   }
audiobookshelf  | }

Additional Notes

No response

Originally created by @JBlond on GitHub (Nov 21, 2024). ### What happened? The server crashes when I try to delete a library ### What did you expect to happen? The library being deleted ### Steps to reproduce the issue 1. Choose a library 2. Click on delete ### Audiobookshelf version v2.17.1 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? Chrome ### Logs ```shell audiobookshelf | Config /config /metadata audiobookshelf | [2024-11-21 16:26:40.871] INFO: === Starting Server === audiobookshelf | [2024-11-21 16:26:40.880] INFO: [Server] Init v2.17.1 audiobookshelf | [2024-11-21 16:26:40.881] INFO: [Server] Node.js Version: v20.18.0 audiobookshelf | [2024-11-21 16:26:40.881] INFO: [Server] Platform: linux audiobookshelf | [2024-11-21 16:26:40.882] INFO: [Server] Arch: x64 audiobookshelf | [2024-11-21 16:26:40.893] INFO: [Database] Initializing db at "/config/absdatabase.sqlite" audiobookshelf | [2024-11-21 16:26:40.931] INFO: [Database] Loading extension /usr/local/lib/nusqlite3/libnusqlite3.so audiobookshelf | [2024-11-21 16:26:40.932] INFO: [Database] Successfully loaded extension /usr/local/lib/nusqlite3/libnusqlite3.so audiobookshelf | [2024-11-21 16:26:40.932] INFO: [Database] Db supports unaccent and unicode foldings audiobookshelf | [2024-11-21 16:26:40.933] INFO: [Database] Db connection was successful audiobookshelf | [2024-11-21 16:26:40.957] INFO: [MigrationManager] Database is already up to date. audiobookshelf | [2024-11-21 16:26:41.248] INFO: [Database] Db initialized with models: user, library, libraryFolder, book, podcast, podcastEpiso de, libraryItem, mediaProgress, series, bookSeries, author, bookAuthor, collection, collectionBook, playlist, playlistMediaItem, device, playbackS ession, feed, feedEpisode, setting, customMetadataProvider, mediaItemShare audiobookshelf | [2024-11-21 16:26:55.566] FATAL: [Server] Unhandled rejection: Error audiobookshelf | at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27) audiobookshelf | at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50 audiobookshelf | at new Promise (<anonymous>) audiobookshelf | at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12) audiobookshelf | at /node_modules/sequelize/lib/sequelize.js:315:28 audiobookshelf | at async SQLiteQueryInterface.bulkDelete (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:403:12) audiobookshelf | at async library.destroy (/node_modules/sequelize/lib/model.js:1838:16) audiobookshelf | at async ApiRouter.delete (/server/controllers/LibraryController.js:508:5) { audiobookshelf | name: 'SequelizeForeignKeyConstraintError', audiobookshelf | parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'" audiobookshelf | }, audiobookshelf | original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'" audiobookshelf | }, audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'", audiobookshelf | parameters: {}, audiobookshelf | table: undefined, audiobookshelf | fields: undefined, audiobookshelf | value: undefined, audiobookshelf | index: undefined, audiobookshelf | reltype: undefined audiobookshelf | } audiobookshelf | promise: Promise { audiobookshelf | <rejected> Error audiobookshelf | at Database.<anonymous> (/node_modules/sequelize/lib/dialects/sqlite/query.js:185:27) audiobookshelf | at /node_modules/sequelize/lib/dialects/sqlite/query.js:183:50 audiobookshelf | at new Promise (<anonymous>) audiobookshelf | at Query.run (/node_modules/sequelize/lib/dialects/sqlite/query.js:183:12) audiobookshelf | at /node_modules/sequelize/lib/sequelize.js:315:28 audiobookshelf | at async SQLiteQueryInterface.bulkDelete (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:403:12) audiobookshelf | at async library.destroy (/node_modules/sequelize/lib/model.js:1838:16) audiobookshelf | at async ApiRouter.delete (/server/controllers/LibraryController.js:508:5) { audiobookshelf | name: 'SequelizeForeignKeyConstraintError', audiobookshelf | parent: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'" audiobookshelf | }, audiobookshelf | original: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] { audiobookshelf | errno: 19, audiobookshelf | code: 'SQLITE_CONSTRAINT', audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'" audiobookshelf | }, audiobookshelf | sql: "DELETE FROM `libraries` WHERE `id` = '69d70105-765c-4f9d-a541-0c3a2858002a'", audiobookshelf | parameters: {}, audiobookshelf | table: undefined, audiobookshelf | fields: undefined, audiobookshelf | value: undefined, audiobookshelf | index: undefined, audiobookshelf | reltype: undefined audiobookshelf | } audiobookshelf | } ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:06:33 +02:00
adam closed this issue 2026-04-25 00:06:33 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 21, 2024):

I can't reproduce this issue. Are you able to share your database or check inside of it for that library?

@advplyr commented on GitHub (Nov 21, 2024): I can't reproduce this issue. Are you able to share your database or check inside of it for that library?
Author
Owner

@JBlond commented on GitHub (Nov 21, 2024):

Can you offer a SQL query? or how do I share my database?

@JBlond commented on GitHub (Nov 21, 2024): Can you offer a SQL query? or how do I share my database?
Author
Owner

@advplyr commented on GitHub (Nov 21, 2024):

You can open the database in a database editor and delete the row in the libraries table.

If you want to share the database so it can be investigated you can send it to me on Discord or email. It is the .sqlite file, you can zip it to make it smaller if it is too large to send.

@advplyr commented on GitHub (Nov 21, 2024): You can open the database in a database editor and delete the row in the libraries table. If you want to share the database so it can be investigated you can send it to me on Discord or email. It is the .sqlite file, you can zip it to make it smaller if it is too large to send.
Author
Owner

@JBlond commented on GitHub (Nov 21, 2024):

I sent it via email to you.

@JBlond commented on GitHub (Nov 21, 2024): I sent it via email to you.
Author
Owner

@JBlond commented on GitHub (Nov 22, 2024):

You should have gotten my email.

@JBlond commented on GitHub (Nov 22, 2024): You should have gotten my email.
Author
Owner

@advplyr commented on GitHub (Nov 22, 2024):

Thanks I got it and was able to reproduce the issue. I'm looking into a fix

@advplyr commented on GitHub (Nov 22, 2024): Thanks I got it and was able to reproduce the issue. I'm looking into a fix
Author
Owner

@github-actions[bot] commented on GitHub (Dec 1, 2024):

Fixed in v2.17.3.

@github-actions[bot] commented on GitHub (Dec 1, 2024): Fixed in [v2.17.3](https://github.com/advplyr/audiobookshelf/releases/tag/v2.17.3).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2368