[Bug]: filterData crashes on new server #2363

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

Originally created by @nichwall on GitHub (Nov 18, 2024).

What happened?

When initializing a new server and creating a library, the filterData can crash. This is due to the bookCount, authorCount, and seriesCount not being defined under Database.libraryFilterData[libraryId].

This was introduced by https://github.com/advplyr/audiobookshelf/pull/3594

What did you expect to happen?

No crash

Steps to reproduce the issue

  1. Create new server
  2. Create library

Audiobookshelf version

2.17.0

How are you running audiobookshelf?

Built from source

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?

None

Logs

[2024-11-17 22:14:35.150] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'bookCount')
    at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77)
    at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) 
promise: Promise {
  <rejected> TypeError: Cannot read properties of undefined (reading 'bookCount')
      at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77)
      at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26)
}

Additional Notes

No response

Originally created by @nichwall on GitHub (Nov 18, 2024). ### What happened? When initializing a new server and creating a library, the `filterData` can crash. This is due to the `bookCount`, `authorCount`, and `seriesCount` not being defined under `Database.libraryFilterData[libraryId]`. This was introduced by https://github.com/advplyr/audiobookshelf/pull/3594 ### What did you expect to happen? No crash ### Steps to reproduce the issue 1. Create new server 2. Create library ### Audiobookshelf version 2.17.0 ### How are you running audiobookshelf? Built from source ### 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? None ### Logs ```shell [2024-11-17 22:14:35.150] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'bookCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) promise: Promise { <rejected> TypeError: Cannot read properties of undefined (reading 'bookCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) } ``` ### Additional Notes _No response_
adam added the bug label 2026-04-25 00:06:31 +02:00
adam closed this issue 2026-04-25 00:06:32 +02:00
Author
Owner

@mascode commented on GitHub (Nov 18, 2024):

I am also getting this error with the podcastCount

2024-11-18 00:13:47 AudioBookShelf  | [2024-11-18 00:13:47.070] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'podcastCount') 
at Object.getFilterData (/server/utils/queries/libraryFilters.js:513:80)
at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) 
promise: Promise {
<rejected> TypeError: Cannot read properties of undefined (reading 'podcastCount')
       at Object.getFilterData (/server/utils/queries/libraryFilters.js:513:80)
      at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26)
}
@mascode commented on GitHub (Nov 18, 2024): I am also getting this error with the `podcastCount` ```shell 2024-11-18 00:13:47 AudioBookShelf | [2024-11-18 00:13:47.070] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'podcastCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:513:80) at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) promise: Promise { <rejected> TypeError: Cannot read properties of undefined (reading 'podcastCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:513:80) at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) } ```
Author
Owner

@nmatton commented on GitHub (Nov 18, 2024):

[2024-11-17 22:14:35.150] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'bookCount')
    at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77)
    at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) 
promise: Promise {
  <rejected> TypeError: Cannot read properties of undefined (reading 'bookCount')
      at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77)
      at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26)
}

This is exactly well described and reproduced on my side too

@nmatton commented on GitHub (Nov 18, 2024): > ```shell > [2024-11-17 22:14:35.150] FATAL: [Server] Unhandled rejection: TypeError: Cannot read properties of undefined (reading 'bookCount') > at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) > at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) > promise: Promise { > <rejected> TypeError: Cannot read properties of undefined (reading 'bookCount') > at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) > at async ApiRouter.findOne (/server/controllers/LibraryController.js:198:26) > } > ``` This is exactly well described and reproduced on my side too
Author
Owner

@luparas95 commented on GitHub (Nov 18, 2024):

I have the same problem

2024-11-18 13:43:23.192

ERROR

[LibraryScanner] Library scan 8d54f270-e55f-4492-a376-d3a10651fcc6 failed after 0:00.0 | 0 Added | 0 Updated | 0 Missing. TypeError: Cannot read properties of undefined (reading 'bookCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) at async LibraryScanner.scanLibrary (/server/scanner/LibraryScanner.js:146:5) at async LibraryScanner.scan (/server/scanner/LibraryScanner.js:89:24) at async ApiRouter.scan (/server/controllers/LibraryController.js:1165:5)
@luparas95 commented on GitHub (Nov 18, 2024): I have the same problem ```shell 2024-11-18 13:43:23.192 ERROR [LibraryScanner] Library scan 8d54f270-e55f-4492-a376-d3a10651fcc6 failed after 0:00.0 | 0 Added | 0 Updated | 0 Missing. TypeError: Cannot read properties of undefined (reading 'bookCount') at Object.getFilterData (/server/utils/queries/libraryFilters.js:616:77) at async LibraryScanner.scanLibrary (/server/scanner/LibraryScanner.js:146:5) at async LibraryScanner.scan (/server/scanner/LibraryScanner.js:89:24) at async ApiRouter.scan (/server/controllers/LibraryController.js:1165:5) ```
Author
Owner

@github-actions[bot] commented on GitHub (Nov 18, 2024):

Fixed in v2.17.1.

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

No dependencies set.

Reference: starred/audiobookshelf#2363