[Bug]: Audiobookshelf becomes unusable when adding a lot of books #1535

Closed
opened 2026-04-24 23:49:11 +02:00 by adam · 3 comments
Owner

Originally created by @lkiesow on GitHub (Nov 19, 2023).

Describe the issue

When adding ~1000 books to my > 2.5.0 (d2aea869) development setup, I noticed that Audiobookshelf became basically unusable for a few minutes since the UI would refresh multiple times a second:

https://github.com/advplyr/audiobookshelf/assets/1008395/edd488ba-9942-4244-99c2-138f9127eb0b

Steps to reproduce the issue

Just generate a lot of new media files in your audiobook folder.
For example with:

❯ mkdir test
❯ ffmpeg -f lavfi -i sine=f=220:b=4 -t 10 -c:a aac -ac 1 -b:a 16k test/test.m4a
❯ for i in {1..1000}; do echo -n "${i}: "; a="$(shuf -n 1 /usr/share/dict/words)"; b="$(shuf -n 1 /usr/share/dict/words)"; mkdir "${a}"; cp -v test/test.m4a "${a}/${b}.m4a"; done

Audiobookshelf version

2.5.0 (d2aea869)

How are you running audiobookshelf?

Built from source

Originally created by @lkiesow on GitHub (Nov 19, 2023). ### Describe the issue When adding ~1000 books to my > 2.5.0 (d2aea869) development setup, I noticed that Audiobookshelf became basically unusable for a few minutes since the UI would refresh multiple times a second: https://github.com/advplyr/audiobookshelf/assets/1008395/edd488ba-9942-4244-99c2-138f9127eb0b ### Steps to reproduce the issue Just generate a lot of new media files in your audiobook folder. For example with: ``` ❯ mkdir test ❯ ffmpeg -f lavfi -i sine=f=220:b=4 -t 10 -c:a aac -ac 1 -b:a 16k test/test.m4a ❯ for i in {1..1000}; do echo -n "${i}: "; a="$(shuf -n 1 /usr/share/dict/words)"; b="$(shuf -n 1 /usr/share/dict/words)"; mkdir "${a}"; cp -v test/test.m4a "${a}/${b}.m4a"; done ``` ### Audiobookshelf version > 2.5.0 (d2aea869) ### How are you running audiobookshelf? Built from source
adam added the bug label 2026-04-24 23:49:11 +02:00
adam closed this issue 2026-04-24 23:49:12 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 19, 2023):

This issue can be resolved in 2 different places in the code.

The cause is that anytime the home page gets a socket event items_added it will make a request to the server to get the home page shelves again if at least one of those items added are in that library.
That happens here: https://github.com/advplyr/audiobookshelf/blob/d2aea8695768aa5d2b911730cb5e120379998fe3/client/components/app/BookShelfCategorized.vue#L297

Solution 1: Instead of fetching new categories again we should just insert the new item in the "Recently Added" shelf. The downside is we won't show potentially new authors or series updates until the page is changed/refreshed.

Solution 2: Instead of emitting the items_added event after every 10 new items scanned in, we only emit that event after X number of seconds have passed since the last event. The socket emit happens in the LibraryScanner here:
https://github.com/advplyr/audiobookshelf/blob/d2aea8695768aa5d2b911730cb5e120379998fe3/server/scanner/LibraryScanner.js#L207

Solution 1 is better I think but we could do both since other clients may listen to that event as well.

@advplyr commented on GitHub (Nov 19, 2023): This issue can be resolved in 2 different places in the code. The cause is that anytime the home page gets a socket event `items_added` it will make a request to the server to get the home page shelves again if at least one of those items added are in that library. That happens here: https://github.com/advplyr/audiobookshelf/blob/d2aea8695768aa5d2b911730cb5e120379998fe3/client/components/app/BookShelfCategorized.vue#L297 Solution 1: Instead of fetching new categories again we should just insert the new item in the "Recently Added" shelf. The downside is we won't show potentially new authors or series updates until the page is changed/refreshed. Solution 2: Instead of emitting the `items_added` event after every 10 new items scanned in, we only emit that event after X number of seconds have passed since the last event. The socket emit happens in the LibraryScanner here: https://github.com/advplyr/audiobookshelf/blob/d2aea8695768aa5d2b911730cb5e120379998fe3/server/scanner/LibraryScanner.js#L207 Solution 1 is better I think but we could do both since other clients may listen to that event as well.
Author
Owner

@lkiesow commented on GitHub (Nov 19, 2023):

I think the first solution is good.

@lkiesow commented on GitHub (Nov 19, 2023): I think the first solution is good.
Author
Owner

@advplyr commented on GitHub (Dec 2, 2023):

Fixed in v2.6.0

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

No dependencies set.

Reference: starred/audiobookshelf#1535