[Bug]: JavaScript heap out of memory on adding item to playlist #3262

Open
opened 2026-04-25 00:14:37 +02:00 by adam · 7 comments
Owner

Originally created by @hp-pepster on GitHub (Mar 17, 2026).

What happened?

Thank you for your great work :-)

Sadly I've got a bug since I set up my ABS (over several releases)
Whenever I try to add a podcast from a library with ~ 2600 items to an existing playlist, the server crashes:

audiobookshelf[575948]: <--- JS stacktrace --->
audiobookshelf[575948]: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Increasing the memory with NODE_OPTIONS=--max-old-space-size=16384 helps, but 8 GiB are not sufficient (logs mentions 12.4G). With the 16 GiB workaround adding an item takes more than 10 s.

Creating a new playlist works fine without any problems (also super fast). Working with other libraries with less items (< 1000) work very well, but the larger the library the longer it takes to add an item to an existing playlist.

Tried with several browsers (e.g. chromium, firefox)

What did you expect to happen?

  • items can be added to playlists, no matter how large the library is
  • adding items to an existing playlist takes the same amount of time as creating a new playlist or adding items from a smaller library

Steps to reproduce the issue

  1. Install ABS under manjaro linux
  2. Add podcast library with more then 2600 items (I don't know the exact number)
  3. Create playlist
  4. Add item from the big library to this existing playlist

Audiobookshelf version

2.33.0

How are you running audiobookshelf?

Other (list in "Additional Notes" box)

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

audiobookshelf[575948]: <--- Last few GCs --->
audiobookshelf[575948]: [575948:0x556bb747ccb0]    40796 ms: Scavenge 8145.0 (8206.1) -> 8144.9 (8217.1) MB, 4.30 / 0.00 ms  (average mu = 0.606, current mu = 0.390) allocation failure;
audiobookshelf[575948]: [575948:0x556bb747ccb0]    40821 ms: Scavenge 8151.7 (8217.1) -> 8152.2 (8217.8) MB, 5.24 / 0.00 ms  (average mu = 0.606, current mu = 0.390) allocation failure;
audiobookshelf[575948]: [575948:0x556bb747ccb0]    41171 ms: Scavenge 8152.5 (8217.8) -> 8151.7 (8240.1) MB, 348.43 / 0.00 ms  (average mu = 0.606, current mu = 0.390) allocation failure;
audiobookshelf[575948]: <--- JS stacktrace --->
audiobookshelf[575948]: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
audiobookshelf[575948]: ----- Native stack trace -----
audiobookshelf[575948]:  1: 0x556b99e91078 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/usr/bin/node]
audiobookshelf[575948]:  2: 0x556b9a2ca114 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/bin/node]
audiobookshelf[575948]:  3: 0x556b9a2ca42d v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/bin/node]
audiobookshelf[575948]:  4: 0x556b9a4ddc3c  [/usr/bin/node]
audiobookshelf[575948]:  5: 0x556b9a4f7eb8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node]
audiobookshelf[575948]:  6: 0x556b9a4d213f v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node]
audiobookshelf[575948]:  7: 0x556b9a4d2fc6 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node]
audiobookshelf[575948]:  8: 0x556b9a4b2735 v8::internal::Factory::AllocateRawWithAllocationSite(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/bin/node]
audiobookshelf[575948]:  9: 0x556b9a4becbc v8::internal::Factory::NewJSObjectFromMap(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/bin/node]
audiobookshelf[575948]: 10: 0x556b9a6118cf v8::internal::JsonParser<unsigned short>::BuildJsonObject(v8::internal::JsonParser<unsigned short>::JsonContinuation const&, v8::base::SmallVector<v8::internal::JsonProperty, 16ul, std::allocator<v8::internal::JsonProperty> > const&, v8::internal::Handle<v8::internal::Map>) [/usr/bin/node]
audiobookshelf[575948]: 11: 0x556b9a619eac  [/usr/bin/node]
audiobookshelf[575948]: 12: 0x556b9a61eab3 v8::internal::JsonParser<unsigned short>::ParseJson(v8::internal::Handle<v8::internal::Object>) [/usr/bin/node]
audiobookshelf[575948]: 13: 0x556b9a36243b v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node]
audiobookshelf[575948]: 14: 0x556b3acd9df6
systemd[1]: audiobookshelf.service: Main process exited, code=dumped, status=6/ABRT
systemd[1]: audiobookshelf.service: Failed with result 'core-dump'.
systemd[1]: audiobookshelf.service: Consumed 33.088s CPU time over 41.816s wall clock time, 12.4G memory peak.

Additional Notes

OS: Manjaro Linux

Originally created by @hp-pepster on GitHub (Mar 17, 2026). ### What happened? Thank you for your great work :-) Sadly I've got a bug since I set up my ABS (over several releases) Whenever I try to add a podcast from a library with ~ 2600 items to an existing playlist, the server crashes: ``` bash audiobookshelf[575948]: <--- JS stacktrace ---> audiobookshelf[575948]: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory ``` Increasing the memory with `NODE_OPTIONS=--max-old-space-size=16384` helps, but 8 GiB are not sufficient (logs mentions 12.4G). With the 16 GiB workaround adding an item takes more than 10 s. Creating a new playlist works fine without any problems (also super fast). Working with other libraries with less items (< 1000) work very well, but the larger the library the longer it takes to add an item to an existing playlist. Tried with several browsers (e.g. chromium, firefox) ### What did you expect to happen? - items can be added to playlists, no matter how large the library is - adding items to an existing playlist takes the same amount of time as creating a new playlist or adding items from a smaller library ### Steps to reproduce the issue 1. Install ABS under manjaro linux 2. Add podcast library with more then 2600 items (I don't know the exact number) 3. Create playlist 4. Add item from the big library to this existing playlist ### Audiobookshelf version 2.33.0 ### How are you running audiobookshelf? Other (list in "Additional Notes" box) ### 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 audiobookshelf[575948]: <--- Last few GCs ---> audiobookshelf[575948]: [575948:0x556bb747ccb0] 40796 ms: Scavenge 8145.0 (8206.1) -> 8144.9 (8217.1) MB, 4.30 / 0.00 ms (average mu = 0.606, current mu = 0.390) allocation failure; audiobookshelf[575948]: [575948:0x556bb747ccb0] 40821 ms: Scavenge 8151.7 (8217.1) -> 8152.2 (8217.8) MB, 5.24 / 0.00 ms (average mu = 0.606, current mu = 0.390) allocation failure; audiobookshelf[575948]: [575948:0x556bb747ccb0] 41171 ms: Scavenge 8152.5 (8217.8) -> 8151.7 (8240.1) MB, 348.43 / 0.00 ms (average mu = 0.606, current mu = 0.390) allocation failure; audiobookshelf[575948]: <--- JS stacktrace ---> audiobookshelf[575948]: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory audiobookshelf[575948]: ----- Native stack trace ----- audiobookshelf[575948]: 1: 0x556b99e91078 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/usr/bin/node] audiobookshelf[575948]: 2: 0x556b9a2ca114 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/bin/node] audiobookshelf[575948]: 3: 0x556b9a2ca42d v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/bin/node] audiobookshelf[575948]: 4: 0x556b9a4ddc3c [/usr/bin/node] audiobookshelf[575948]: 5: 0x556b9a4f7eb8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node] audiobookshelf[575948]: 6: 0x556b9a4d213f v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node] audiobookshelf[575948]: 7: 0x556b9a4d2fc6 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node] audiobookshelf[575948]: 8: 0x556b9a4b2735 v8::internal::Factory::AllocateRawWithAllocationSite(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/bin/node] audiobookshelf[575948]: 9: 0x556b9a4becbc v8::internal::Factory::NewJSObjectFromMap(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType, v8::internal::Handle<v8::internal::AllocationSite>) [/usr/bin/node] audiobookshelf[575948]: 10: 0x556b9a6118cf v8::internal::JsonParser<unsigned short>::BuildJsonObject(v8::internal::JsonParser<unsigned short>::JsonContinuation const&, v8::base::SmallVector<v8::internal::JsonProperty, 16ul, std::allocator<v8::internal::JsonProperty> > const&, v8::internal::Handle<v8::internal::Map>) [/usr/bin/node] audiobookshelf[575948]: 11: 0x556b9a619eac [/usr/bin/node] audiobookshelf[575948]: 12: 0x556b9a61eab3 v8::internal::JsonParser<unsigned short>::ParseJson(v8::internal::Handle<v8::internal::Object>) [/usr/bin/node] audiobookshelf[575948]: 13: 0x556b9a36243b v8::internal::Builtin_JsonParse(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node] audiobookshelf[575948]: 14: 0x556b3acd9df6 systemd[1]: audiobookshelf.service: Main process exited, code=dumped, status=6/ABRT systemd[1]: audiobookshelf.service: Failed with result 'core-dump'. systemd[1]: audiobookshelf.service: Consumed 33.088s CPU time over 41.816s wall clock time, 12.4G memory peak. ``` ### Additional Notes OS: Manjaro Linux
adam added the bug label 2026-04-25 00:14:37 +02:00
Author
Owner

@nichwall commented on GitHub (Mar 17, 2026):

Related to https://github.com/advplyr/audiobookshelf/issues/2177

Collections and playlists are not paginated and have performance issues when they get sufficiently large.

@nichwall commented on GitHub (Mar 17, 2026): Related to https://github.com/advplyr/audiobookshelf/issues/2177 Collections and playlists are not paginated and have performance issues when they get sufficiently large.
Author
Owner

@hp-pepster commented on GitHub (Mar 17, 2026):

@nichwall thank you for your answer. So I have to wait until the problem with large libs is solved.

Just to clarify: The problem occurs even if there is only one item in the playlist and that item is from a library with only ~ 10 items.
What I do not understand is why there is no problem if I create a new playlist. Somehow the number of queries or whatever are different if a new playlist is created or an item gets added to an existing playlist.

@hp-pepster commented on GitHub (Mar 17, 2026): @nichwall thank you for your answer. So I have to wait until the problem with large libs is solved. Just to clarify: The problem occurs even if there is only one item in the playlist and that item is from a library with only ~ 10 items. What I do not understand is why there is no problem if I create a new playlist. Somehow the number of queries or whatever are different if a new playlist is created or an item gets added to an existing playlist.
Author
Owner

@nichwall commented on GitHub (Mar 18, 2026):

Huh, that is interesting. Thanks for clarifying.

If you are willing to send me a backup of your database (can just be the zip) I can take a look at what exactly is happening and put more details here. An email with the attachment or a link to download will work, you can send it to the email on my GH profile. It will be a few days before I can sit down and go through it, but I can download it whenever is convenient so you don't need to leave it available somewhere.

@nichwall commented on GitHub (Mar 18, 2026): Huh, that is interesting. Thanks for clarifying. If you are willing to send me a backup of your database (can just be the zip) I can take a look at what exactly is happening and put more details here. An email with the attachment or a link to download will work, you can send it to the email on my GH profile. It will be a few days before I can sit down and go through it, but I can download it whenever is convenient so you don't need to leave it available somewhere.
Author
Owner

@hp-pepster commented on GitHub (Mar 18, 2026):

You've got mail. Please take your time, I can imagine you have better things to do than debugging/fixing this.

@hp-pepster commented on GitHub (Mar 18, 2026): You've got mail. Please take your time, I can imagine you have better things to do than debugging/fixing this.
Author
Owner

@nichwall commented on GitHub (Mar 23, 2026):

Thanks! I have downloaded your database backup and was able to reproduce the behavior. It looks like it may be related to having a lot of podcast episodes available on the server (I tested adding one episode of the 2000+ episode podcasts to a small existing playlist).

It looks like the issue is due to /api/playlists/:id/batch/add loading the entire podcast into memory to add the single episode to a playlist (this is a problem with a number of podcast related queries that probably needs to be cleaned up). I'll see if there is a simple way to clean up the queries for this endpoint.

@nichwall commented on GitHub (Mar 23, 2026): Thanks! I have downloaded your database backup and was able to reproduce the behavior. It looks like it may be related to having a lot of podcast episodes available on the server (I tested adding one episode of the 2000+ episode podcasts to a small existing playlist). It looks like the issue is due to `/api/playlists/:id/batch/add` loading the entire podcast into memory to add the single episode to a playlist (this is a problem with a number of podcast related queries that probably needs to be cleaned up). I'll see if there is a simple way to clean up the queries for this endpoint.
Author
Owner

@hp-pepster commented on GitHub (Mar 23, 2026):

I have to thank you, fixing this on the weekend at night. 🙇
I've already tested it. At least from my point of view it's working like a charm.

Edit: Should I close the ticket or wait for your PR to get merged?

@hp-pepster commented on GitHub (Mar 23, 2026): I have to thank you, fixing this on the weekend at night. 🙇 I've already tested it. At least from my point of view it's working like a charm. _Edit: Should I close the ticket or wait for your PR to get merged?_
Author
Owner

@nichwall commented on GitHub (Mar 23, 2026):

I would wait for to be merged because that will automatically close this issue. It might be a bit before it is merged and that makes sure the issue doesn't get lost if so.

@nichwall commented on GitHub (Mar 23, 2026): I would wait for to be merged because that will automatically close this issue. It might be a bit before it is merged and that makes sure the issue doesn't get lost if so.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#3262