[Bug]: JavaScript heap out of memory #1841

Closed
opened 2026-04-24 23:59:40 +02:00 by adam · 8 comments
Owner

Originally created by @HersheyTaichou on GitHub (Mar 27, 2024).

Describe the issue

With a fresh install, when trying to do an initial scan of the library, the docker container will crash. The docker logs indicate that it is running out of memory. It tried adding the following to my compose file, but it still crashed after consuming about 9G of RAM as shown in Portainer.

    deploy:
      resources:
        limits:
          memory: 16G

Here is the docker log from when I started a scan to when the container crashed:

[2024-03-27 09:31:56.961] INFO: [LibraryScanner] Starting (forced) library scan 8e8a6f95-a3c3-4e2d-8c1b-791076035976 for Audiobooks
<--- Last few GCs --->
[7:0x7f4041c8a680]  1623939 ms: Scavenge 3980.8 (4120.6) -> 3970.2 (4122.1) MB, 7.65 / 0.00 ms  (average mu = 0.208, current mu = 0.016) task; 
[7:0x7f4041c8a680]  1624043 ms: Scavenge 3983.4 (4123.1) -> 3972.8 (4124.6) MB, 9.69 / 0.00 ms  (average mu = 0.208, current mu = 0.016) task; 
[7:0x7f4041c8a680]  1624143 ms: Scavenge 3985.8 (4125.6) -> 3975.2 (4127.3) MB, 6.24 / 0.00 ms  (average mu = 0.208, current mu = 0.016) task; 
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

Here is the log from Audiobookshelf from when I enabled debugging, started a scan, and the container restarted

{"timestamp":"2024-03-27 09:31:19.212","source":"Logger.js:102","message":"Set Log Level to DEBUG","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:19.229","source":"ApiCacheManager.js:21","message":"[ApiCacheManager] Array.afterUpsert: Clearing cache","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.575","source":"ApiCacheManager.js:39","message":"[ApiCacheManager] count: 0 size: 0","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.603","source":"ApiCacheManager.js:50","message":"[ApiCacheManager] Cache miss: {\"user\":\"root\",\"url\":\"/libraries/9025cd21-943d-4635-8be6-02223db8e39f?include=filterdata\"}","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.664","source":"ApiCacheManager.js:39","message":"[ApiCacheManager] count: 1 size: 1053","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.726","source":"LibraryItem.js:611","message":"Loaded 0 of 0 items for \"Continue Listening/Reading\" in 0.05s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.773","source":"LibraryItem.js:628","message":"Loaded 0 of 0 items for \"Continue Series\" in 0.05s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.814","source":"LibraryItem.js:658","message":"Loaded 0 of 0 items for \"Recently Added\" in 0.04s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.848","source":"LibraryItem.js:674","message":"Loaded 0 of 0 series for \"Recent Series\" in 0.03s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.910","source":"LibraryItem.js:689","message":"Loaded 0 of 0 items for \"Discover\" in 0.06s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:55.995","source":"LibraryItem.js:720","message":"Loaded 0 of 0 items for \"Listen/Read Again\" in 0.09s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:56.024","source":"LibraryItem.js:736","message":"Loaded 0 of 0 authors for \"Newest Authors\" in 0.03s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:56.024","source":"LibraryItem.js:739","message":"Loaded 0 personalized shelves in 0.35s","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:56.025","source":"ApiCacheManager.js:50","message":"[ApiCacheManager] Cache miss: {\"user\":\"root\",\"url\":\"/libraries/9025cd21-943d-4635-8be6-02223db8e39f/personalized?include=rssfeed,numEpisodesIncomplete\"}","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:56.025","source":"ApiCacheManager.js:53","message":"[ApiCacheManager] Caching with 1800000 ms TTL","levelName":"DEBUG","level":1}
{"timestamp":"2024-03-27 09:31:56.959","source":"LibraryScanner.js:64","message":"[LibraryScanner] Library metadata precedence changed since last scan. From [Unset] to [folderStructure,audioMetatags,nfoFile,txtFiles,opfFile,absMetadata]","levelName":"INFO","level":2}
{"timestamp":"2024-03-27 09:31:56.962","source":"LibraryScanner.js:80","message":"[LibraryScanner] Starting (forced) library scan 8e8a6f95-a3c3-4e2d-8c1b-791076035976 for Audiobooks","levelName":"INFO","level":2}
{"timestamp":"2024-03-27 09:50:58.421","source":"LogManager.js:71","message":"[LogManager] Daily log file already exists - set in Logger","levelName":"DEBUG","level":1}

Steps to reproduce the issue

  1. Deploy a new docker stack of ABS
  2. Start an initial scan of the audiobook library

Audiobookshelf version

2.8.1

How are you running audiobookshelf?

Docker

Originally created by @HersheyTaichou on GitHub (Mar 27, 2024). ### Describe the issue With a fresh install, when trying to do an initial scan of the library, the docker container will crash. The docker logs indicate that it is running out of memory. It tried adding the following to my compose file, but it still crashed after consuming about 9G of RAM as shown in Portainer. ```docker-compose deploy: resources: limits: memory: 16G ``` Here is the docker log from when I started a scan to when the container crashed: ```text [2024-03-27 09:31:56.961] INFO: [LibraryScanner] Starting (forced) library scan 8e8a6f95-a3c3-4e2d-8c1b-791076035976 for Audiobooks <--- Last few GCs ---> [7:0x7f4041c8a680] 1623939 ms: Scavenge 3980.8 (4120.6) -> 3970.2 (4122.1) MB, 7.65 / 0.00 ms (average mu = 0.208, current mu = 0.016) task; [7:0x7f4041c8a680] 1624043 ms: Scavenge 3983.4 (4123.1) -> 3972.8 (4124.6) MB, 9.69 / 0.00 ms (average mu = 0.208, current mu = 0.016) task; [7:0x7f4041c8a680] 1624143 ms: Scavenge 3985.8 (4125.6) -> 3975.2 (4127.3) MB, 6.24 / 0.00 ms (average mu = 0.208, current mu = 0.016) task; <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ----- Native stack trace ----- ``` Here is the log from Audiobookshelf from when I enabled debugging, started a scan, and the container restarted ```text {"timestamp":"2024-03-27 09:31:19.212","source":"Logger.js:102","message":"Set Log Level to DEBUG","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:19.229","source":"ApiCacheManager.js:21","message":"[ApiCacheManager] Array.afterUpsert: Clearing cache","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.575","source":"ApiCacheManager.js:39","message":"[ApiCacheManager] count: 0 size: 0","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.603","source":"ApiCacheManager.js:50","message":"[ApiCacheManager] Cache miss: {\"user\":\"root\",\"url\":\"/libraries/9025cd21-943d-4635-8be6-02223db8e39f?include=filterdata\"}","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.664","source":"ApiCacheManager.js:39","message":"[ApiCacheManager] count: 1 size: 1053","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.726","source":"LibraryItem.js:611","message":"Loaded 0 of 0 items for \"Continue Listening/Reading\" in 0.05s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.773","source":"LibraryItem.js:628","message":"Loaded 0 of 0 items for \"Continue Series\" in 0.05s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.814","source":"LibraryItem.js:658","message":"Loaded 0 of 0 items for \"Recently Added\" in 0.04s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.848","source":"LibraryItem.js:674","message":"Loaded 0 of 0 series for \"Recent Series\" in 0.03s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.910","source":"LibraryItem.js:689","message":"Loaded 0 of 0 items for \"Discover\" in 0.06s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:55.995","source":"LibraryItem.js:720","message":"Loaded 0 of 0 items for \"Listen/Read Again\" in 0.09s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:56.024","source":"LibraryItem.js:736","message":"Loaded 0 of 0 authors for \"Newest Authors\" in 0.03s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:56.024","source":"LibraryItem.js:739","message":"Loaded 0 personalized shelves in 0.35s","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:56.025","source":"ApiCacheManager.js:50","message":"[ApiCacheManager] Cache miss: {\"user\":\"root\",\"url\":\"/libraries/9025cd21-943d-4635-8be6-02223db8e39f/personalized?include=rssfeed,numEpisodesIncomplete\"}","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:56.025","source":"ApiCacheManager.js:53","message":"[ApiCacheManager] Caching with 1800000 ms TTL","levelName":"DEBUG","level":1} {"timestamp":"2024-03-27 09:31:56.959","source":"LibraryScanner.js:64","message":"[LibraryScanner] Library metadata precedence changed since last scan. From [Unset] to [folderStructure,audioMetatags,nfoFile,txtFiles,opfFile,absMetadata]","levelName":"INFO","level":2} {"timestamp":"2024-03-27 09:31:56.962","source":"LibraryScanner.js:80","message":"[LibraryScanner] Starting (forced) library scan 8e8a6f95-a3c3-4e2d-8c1b-791076035976 for Audiobooks","levelName":"INFO","level":2} {"timestamp":"2024-03-27 09:50:58.421","source":"LogManager.js:71","message":"[LogManager] Daily log file already exists - set in Logger","levelName":"DEBUG","level":1} ``` ### Steps to reproduce the issue 1. Deploy a new docker stack of ABS 2. Start an initial scan of the audiobook library ### Audiobookshelf version 2.8.1 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:59:40 +02:00
adam closed this issue 2026-04-24 23:59:40 +02:00
Author
Owner

@nichwall commented on GitHub (Mar 27, 2024):

Are there any ebook files in the library (PDF, CBZ, CBR, epub)?

@nichwall commented on GitHub (Mar 27, 2024): Are there any ebook files in the library (PDF, CBZ, CBR, epub)?
Author
Owner

@HersheyTaichou commented on GitHub (Mar 27, 2024):

I have 7 books with supplemental PDF files in the same folder as the .m4b and 134 .m4b files total in the library

@HersheyTaichou commented on GitHub (Mar 27, 2024): I have 7 books with supplemental PDF files in the same folder as the .m4b and 134 .m4b files total in the library
Author
Owner

@advplyr commented on GitHub (Mar 27, 2024):

Are you using a network file system? Can you try creating a library with just a few m4b files to test that you can scan in books?

@advplyr commented on GitHub (Mar 27, 2024): Are you using a network file system? Can you try creating a library with just a few m4b files to test that you can scan in books?
Author
Owner

@HersheyTaichou commented on GitHub (Mar 27, 2024):

The books are stored on an NFS share. I tried just 5 books, one of which did have a supplemental PDF, with the same result. I just deleted the supplemental PDF, and re-ran the scan with the same result.

@HersheyTaichou commented on GitHub (Mar 27, 2024): The books are stored on an NFS share. I tried just 5 books, one of which did have a supplemental PDF, with the same result. I just deleted the supplemental PDF, and re-ran the scan with the same result.
Author
Owner

@advplyr commented on GitHub (Mar 27, 2024):

You can't scan in a library with a single audio file? Can you share your docker compose?

@advplyr commented on GitHub (Mar 27, 2024): You can't scan in a library with a single audio file? Can you share your docker compose?
Author
Owner

@HersheyTaichou commented on GitHub (Mar 28, 2024):

Sorry, I just started a scan with just one m4b file in the library, but it did the same thing. Here is my compose file:

version: "3.7"
services:
  audiobookshelf:
    image: ghcr.io/advplyr/audiobookshelf:latest
    restart: unless-stopped
    ports:
      - 13378:80
    volumes:
      - /media/nfs-share/Media/Temp-Audiobook:/audiobooks
      - /media/nfs-share/Media/podcasts:/podcasts
      - /srv/audiobookshelf/config:/config
      - /media/nfs-share/srv/audiobookshelf/metadata:/metadata
    environment:
      - TZ=America/New_York
    healthcheck:
      test: ["CMD", "wget" ,"--no-verbose", "--tries=1", "--spider", "http://localhost"]
      interval: 1m
      timeout: 3s
@HersheyTaichou commented on GitHub (Mar 28, 2024): Sorry, I just started a scan with just one m4b file in the library, but it did the same thing. Here is my compose file: ``` version: "3.7" services: audiobookshelf: image: ghcr.io/advplyr/audiobookshelf:latest restart: unless-stopped ports: - 13378:80 volumes: - /media/nfs-share/Media/Temp-Audiobook:/audiobooks - /media/nfs-share/Media/podcasts:/podcasts - /srv/audiobookshelf/config:/config - /media/nfs-share/srv/audiobookshelf/metadata:/metadata environment: - TZ=America/New_York healthcheck: test: ["CMD", "wget" ,"--no-verbose", "--tries=1", "--spider", "http://localhost"] interval: 1m timeout: 3s ```
Author
Owner

@HersheyTaichou commented on GitHub (Mar 28, 2024):

Welp... I'm an idiot, and sorry for wasting your time... I somehow accidentally mapped the root ( / ) as the audiobook library, instead of /audiobooks.

image

@HersheyTaichou commented on GitHub (Mar 28, 2024): Welp... I'm an idiot, and sorry for wasting your time... I somehow accidentally mapped the root ( / ) as the audiobook library, instead of /audiobooks. ![image](https://github.com/advplyr/audiobookshelf/assets/56273704/23698d68-bf9c-4fd1-90ba-c67aa824c7d2)
Author
Owner

@advplyr commented on GitHub (Mar 28, 2024):

No prob, glad you got it figured out

@advplyr commented on GitHub (Mar 28, 2024): No prob, glad you got it figured out
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1841