[Bug]: Crash during Library Scan #713

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

Originally created by @Baschdl578 on GitHub (Oct 25, 2022).

Describe the issue

The entire server crashes when I scan my library.
It's probably an issue with some specific files, regardless, this shouldn't crash the entire app.

[2022-10-25 10:23:47]  INFO: [Scanner] Starting library scan lscan_vc9twa4njkjx4m6evq for Audiobooks
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/02 - Eclipse 02.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/03 - Eclipse 03.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/04 - Eclipse 04.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/05 - Eclipse 05.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/06 - Eclipse 06.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/07 - Eclipse 07.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/08 - Eclipse 08.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/09 - Eclipse 09.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/10 - Eclipse 10.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/11 - Eclipse 11.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/12 - Eclipse 12.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/13 - Eclipse 13.mp3"
[2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/14 - Eclipse 14.mp3"
/server/libs/njodb/index.js:103
        throw error;
        ^
Error: spawn ffprobe EMFILE
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -24,
  code: 'EMFILE',
  syscall: 'spawn ffprobe',
  path: 'ffprobe',
  spawnargs: [
    '-hide_banner',
    '-loglevel',
    'fatal',
    '-show_error',
    '-show_format',
    '-show_streams',
    '-show_programs',
    '-show_chapters',
    '-show_private_data',
    '-print_format',
    'json',
    '/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/02 - Eclipse 02.mp3'
  ]
}

Steps to reproduce the issue

  1. Set up new Audiobookshelf server in docker
  2. Add new Library
  3. Scan Library
    It's probably an issue with the files

Audiobookshelf version

v2.2.1

How are you running audiobookshelf?

Docker

Originally created by @Baschdl578 on GitHub (Oct 25, 2022). ### Describe the issue The entire server crashes when I scan my library. It's probably an issue with some specific files, regardless, this shouldn't crash the entire app. ``` [2022-10-25 10:23:47] INFO: [Scanner] Starting library scan lscan_vc9twa4njkjx4m6evq for Audiobooks [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/02 - Eclipse 02.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/03 - Eclipse 03.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/04 - Eclipse 04.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/05 - Eclipse 05.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/06 - Eclipse 06.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/07 - Eclipse 07.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/08 - Eclipse 08.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/09 - Eclipse 09.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/10 - Eclipse 10.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/11 - Eclipse 11.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/12 - Eclipse 12.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/13 - Eclipse 13.mp3" [2022-10-25 10:23:50] ERROR: [MediaFileScanner] TypeError: Cannot read properties of undefined (reading 'setEncoding') : "/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/14 - Eclipse 14.mp3" /server/libs/njodb/index.js:103 throw error; ^ Error: spawn ffprobe EMFILE at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -24, code: 'EMFILE', syscall: 'spawn ffprobe', path: 'ffprobe', spawnargs: [ '-hide_banner', '-loglevel', 'fatal', '-show_error', '-show_format', '-show_streams', '-show_programs', '-show_chapters', '-show_private_data', '-print_format', 'json', '/audiobooks/Stephenie Meyer/Twilight Saga Book 3 of 4 - Eclipse/02 - Eclipse 02.mp3' ] } ``` ### Steps to reproduce the issue 1. Set up new Audiobookshelf server in docker 2. Add new Library 3. Scan Library It's probably an issue with the files ### Audiobookshelf version v2.2.1 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:17:55 +02:00
adam closed this issue 2026-04-24 23:17:55 +02:00
Author
Owner

@advplyr commented on GitHub (Oct 25, 2022):

I'm not sure how to catch this error and it seems like an issue we would want to shut down the server.

The error code EMFILE means that a process is trying to open too many files. Unix systems have a max number of file descriptors that may be assigned, also known as the MAX_OPEN value. On OS X, the default is 256, which is pretty low for many modern programs that do a lot of file system writing and reading.

This makes me think that whatever issue there is with those audio files it is causing ffprobe to not close the files properly.

If you can provide anymore information that can explain what is causing this it would be helpful.

@advplyr commented on GitHub (Oct 25, 2022): I'm not sure how to catch this error and it seems like an issue we would want to shut down the server. ``` The error code EMFILE means that a process is trying to open too many files. Unix systems have a max number of file descriptors that may be assigned, also known as the MAX_OPEN value. On OS X, the default is 256, which is pretty low for many modern programs that do a lot of file system writing and reading. ``` This makes me think that whatever issue there is with those audio files it is causing ffprobe to not close the files properly. If you can provide anymore information that can explain what is causing this it would be helpful.
Author
Owner

@Baschdl578 commented on GitHub (Oct 26, 2022):

It seems the open files limit in docker containers is different to the one set on the host. I thought this was a kernel setting...
Simply adding these lines to my compose file solved this issue:

services:
  audiobookshelf:
    ulimits:
      nofile:
        soft: "65536"
        hard: "65536"
    ...

Maybe add these to the example in the documentation?

@Baschdl578 commented on GitHub (Oct 26, 2022): It seems the open files limit in docker containers is different to the one set on the host. I thought this was a kernel setting... Simply adding these lines to my compose file solved this issue: ``` services: audiobookshelf: ulimits: nofile: soft: "65536" hard: "65536" ... ``` Maybe add these to the example in the documentation?
Author
Owner

@advplyr commented on GitHub (Oct 26, 2022):

This doesn't seem right, the docker container shouldn't ever need to open that many files. Again, I think there is something going on with your setup. I suggest keeping an eye on that docker container that it isn't using too much memory.

@advplyr commented on GitHub (Oct 26, 2022): This doesn't seem right, the docker container shouldn't ever need to open that many files. Again, I think there is something going on with your setup. I suggest keeping an eye on that docker container that it isn't using too much memory.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#713