[BUG] EMFILE: Too many open files #1680

Closed
opened 2026-02-05 03:03:18 +03:00 by OVERLORD · 37 comments
Owner

Originally created by @esmoyer on GitHub (Nov 23, 2023).

Originally assigned to: @etnoy on GitHub.

The bug

Attempting to run immich upload using the CLI and get this error:

root@immichLXC:/mnt/media/Photos/ImmichPhotos/library# immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/
node:events:493
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, open '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -24,
  code: 'EMFILE',
  syscall: 'open',
  path: '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg'
}

Node.js v21.0.0

The OS that Immich Server is running on

Debian 12

Version of Immich Server

1.88.2

Version of Immich Mobile App

1.88.2

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

version: "3.8"
#
# WARNING: Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
#

name: immich
services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command:
      - start.sh
      - immich
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
      - typesense
    restart: always
  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends:
    #   file: hwaccel.yml
    #   service: hwaccel
    command:
      - start.sh
      - microservices
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
      - typesense
    restart: always
  immich-machine-learning:
    container_name: immich_machine_learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    volumes:
      - /opt/stacks/immich/model-cache:/cache
    env_file:
      - .env
    restart: always
  typesense:
    container_name: immich_typesense
    image: typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd
    environment:
      - TYPESENSE_API_KEY=${TYPESENSE_API_KEY}
      - TYPESENSE_DATA_DIR=/data
      - GLOG_minloglevel=1
    volumes:
      - /opt/stacks/immich/tsdata:/data
    restart: always
  redis:
    container_name: immich_redis
    image: redis:6.2-alpine@sha256:80cc8518800438c684a53ed829c621c94afd1087aaeb59b0d4343ed3e7bcf6c5
    restart: always
  database:
    container_name: immich_postgres
    image: postgres:14-alpine@sha256:50d9be76e9a90da4c781554955e0ffc79d9d5c4226838e64b36aacc97cbc35ad
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
    volumes:
      - /opt/stacks/immich/pgdata:/var/lib/postgresql/data
    restart: always
networks: {}

Your .env content

###################################################################################
# Database
###################################################################################

DB_HOSTNAME=immich_postgres
DB_USERNAME=XXX
DB_PASSWORD=XXX
DB_DATABASE_NAME=immich

# Optional Database settings:
# DB_PORT=5432

###################################################################################
# Redis
###################################################################################

REDIS_HOSTNAME=immich_redis

# Optional Redis settings:
# REDIS_PORT=6379
# REDIS_DBINDEX=0
# REDIS_PASSWORD=XXXX
# REDIS_SOCKET=

###################################################################################
# Upload File Location 
#
# This is the location where uploaded files are stored.
###################################################################################

UPLOAD_LOCATION=/mnt/media/photos/ImmichPhotos

###################################################################################
# Typesense
###################################################################################
TYPESENSE_API_KEY=XXXX
# TYPESENSE_ENABLED=false

###################################################################################
# Reverse Geocoding
#
# Reverse geocoding is done locally which has a small impact on memory usage
# This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable
# This ranges from 0-3 with 3 being the most precise
# 3 - Cities > 500 population: ~200MB RAM
# 2 - Cities > 1000 population: ~150MB RAM
# 1 - Cities > 5000 population: ~80MB RAM
# 0 - Cities > 15000 population: ~40MB RAM
####################################################################################

DISABLE_REVERSE_GEOCODING=false
REVERSE_GEOCODING_PRECISION=3

####################################################################################
# WEB - Optional
#
# Custom message on the login page, should be written in HTML form.
# For example:
# PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>"
####################################################################################

PUBLIC_LOGIN_PAGE_MESSAGE=

####################################################################################
# Alternative Service Addresses - Optional
#
# This is an advanced feature for users who may be running their immich services on different hosts.
# It will not change which address or port that services bind to within their containers, but it will change where other services look for their peers.
# Note: immich-microservices is bound to 3002, but no references are made
####################################################################################

IMMICH_WEB_URL=http://immich-web:8555
IMMICH_SERVER_URL=http://immich-server:3001
IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003

####################################################################################
# Alternative API's External Address - Optional
#
# This is an advanced feature used to control the public server endpoint returned to clients during Well-known discovery.
# You should only use this if you want mobile apps to access the immich API over a custom URL. Do not include trailing slash.
# NOTE: At this time, the web app will not be affected by this setting and will continue to use the relative path: /api
# Examples: http://localhost:3001, http://immich-api.example.com, etc
####################################################################################

#IMMICH_API_URL_EXTERNAL=http://localhost:3001

Reproduction steps

1. Run `immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/`
2. Wait a few minutes
3. Get the following errors:


root@immichLXC:/mnt/media/Photos/ImmichPhotos/library# immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/
node:events:493
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, open '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -24,
  code: 'EMFILE',
  syscall: 'open',
  path: '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg'
}

Node.js v21.0.0
...

Additional information

Tried with fresh Immich install; updated node and npm; on latest version of CLI tool

Originally created by @esmoyer on GitHub (Nov 23, 2023). Originally assigned to: @etnoy on GitHub. ### The bug Attempting to run immich upload using the CLI and get this error: ``` root@immichLXC:/mnt/media/Photos/ImmichPhotos/library# immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/ node:events:493 throw er; // Unhandled 'error' event ^ Error: EMFILE: too many open files, open '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg' Emitted 'error' event on ReadStream instance at: at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -24, code: 'EMFILE', syscall: 'open', path: '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg' } Node.js v21.0.0 ``` ### The OS that Immich Server is running on Debian 12 ### Version of Immich Server 1.88.2 ### Version of Immich Mobile App 1.88.2 ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML version: "3.8" # # WARNING: Make sure to use the docker-compose.yml of the current release: # # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml # # The compose file on main may not be compatible with the latest release. # name: immich services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} command: - start.sh - immich volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - 2283:3001 depends_on: - redis - database - typesense restart: always immich-microservices: container_name: immich_microservices image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} # extends: # file: hwaccel.yml # service: hwaccel command: - start.sh - microservices volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env depends_on: - redis - database - typesense restart: always immich-machine-learning: container_name: immich_machine_learning image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} volumes: - /opt/stacks/immich/model-cache:/cache env_file: - .env restart: always typesense: container_name: immich_typesense image: typesense/typesense:0.24.1@sha256:9bcff2b829f12074426ca044b56160ca9d777a0c488303469143dd9f8259d4dd environment: - TYPESENSE_API_KEY=${TYPESENSE_API_KEY} - TYPESENSE_DATA_DIR=/data - GLOG_minloglevel=1 volumes: - /opt/stacks/immich/tsdata:/data restart: always redis: container_name: immich_redis image: redis:6.2-alpine@sha256:80cc8518800438c684a53ed829c621c94afd1087aaeb59b0d4343ed3e7bcf6c5 restart: always database: container_name: immich_postgres image: postgres:14-alpine@sha256:50d9be76e9a90da4c781554955e0ffc79d9d5c4226838e64b36aacc97cbc35ad env_file: - .env environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} volumes: - /opt/stacks/immich/pgdata:/var/lib/postgresql/data restart: always networks: {} ``` ### Your .env content ```Shell ################################################################################### # Database ################################################################################### DB_HOSTNAME=immich_postgres DB_USERNAME=XXX DB_PASSWORD=XXX DB_DATABASE_NAME=immich # Optional Database settings: # DB_PORT=5432 ################################################################################### # Redis ################################################################################### REDIS_HOSTNAME=immich_redis # Optional Redis settings: # REDIS_PORT=6379 # REDIS_DBINDEX=0 # REDIS_PASSWORD=XXXX # REDIS_SOCKET= ################################################################################### # Upload File Location # # This is the location where uploaded files are stored. ################################################################################### UPLOAD_LOCATION=/mnt/media/photos/ImmichPhotos ################################################################################### # Typesense ################################################################################### TYPESENSE_API_KEY=XXXX # TYPESENSE_ENABLED=false ################################################################################### # Reverse Geocoding # # Reverse geocoding is done locally which has a small impact on memory usage # This memory usage can be altered by changing the REVERSE_GEOCODING_PRECISION variable # This ranges from 0-3 with 3 being the most precise # 3 - Cities > 500 population: ~200MB RAM # 2 - Cities > 1000 population: ~150MB RAM # 1 - Cities > 5000 population: ~80MB RAM # 0 - Cities > 15000 population: ~40MB RAM #################################################################################### DISABLE_REVERSE_GEOCODING=false REVERSE_GEOCODING_PRECISION=3 #################################################################################### # WEB - Optional # # Custom message on the login page, should be written in HTML form. # For example: # PUBLIC_LOGIN_PAGE_MESSAGE="This is a demo instance of Immich.<br><br>Email: <i>demo@demo.de</i><br>Password: <i>demo</i>" #################################################################################### PUBLIC_LOGIN_PAGE_MESSAGE= #################################################################################### # Alternative Service Addresses - Optional # # This is an advanced feature for users who may be running their immich services on different hosts. # It will not change which address or port that services bind to within their containers, but it will change where other services look for their peers. # Note: immich-microservices is bound to 3002, but no references are made #################################################################################### IMMICH_WEB_URL=http://immich-web:8555 IMMICH_SERVER_URL=http://immich-server:3001 IMMICH_MACHINE_LEARNING_URL=http://immich-machine-learning:3003 #################################################################################### # Alternative API's External Address - Optional # # This is an advanced feature used to control the public server endpoint returned to clients during Well-known discovery. # You should only use this if you want mobile apps to access the immich API over a custom URL. Do not include trailing slash. # NOTE: At this time, the web app will not be affected by this setting and will continue to use the relative path: /api # Examples: http://localhost:3001, http://immich-api.example.com, etc #################################################################################### #IMMICH_API_URL_EXTERNAL=http://localhost:3001 ``` ### Reproduction steps ```bash 1. Run `immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/` 2. Wait a few minutes 3. Get the following errors: root@immichLXC:/mnt/media/Photos/ImmichPhotos/library# immich upload --dry-run --recursive /mnt/media/Photos/Immich/library/eric/ node:events:493 throw er; // Unhandled 'error' event ^ Error: EMFILE: too many open files, open '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg' Emitted 'error' event on ReadStream instance at: at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -24, code: 'EMFILE', syscall: 'open', path: '/mnt/media/Photos/Immich/library/eric/1985/01/Dec84-May86 (216)+1.jpg' } Node.js v21.0.0 ... ``` ### Additional information Tried with fresh Immich install; updated node and npm; on latest version of CLI tool
OVERLORD added the cli label 2026-02-05 03:03:18 +03:00
Author
Owner

@AlexGuld commented on GitHub (Nov 23, 2023):

I had same error when trying to upload large amount of files. splitting it up worked for me. it failed when uploading above ∼10000 files from what I experienced.

@AlexGuld commented on GitHub (Nov 23, 2023): I had same error when trying to upload large amount of files. splitting it up worked for me. it failed when uploading above ∼10000 files from what I experienced.
Author
Owner

@esmoyer commented on GitHub (Nov 23, 2023):

Thanks @zaico, I just tried that and it seems to work, but it skipped some of my video files. Going to try and start fresh again and see how it goes.

@esmoyer commented on GitHub (Nov 23, 2023): Thanks @zaico, I just tried that and it seems to work, but it skipped some of my video files. Going to try and start fresh again and see how it goes.
Author
Owner

@alextran1502 commented on GitHub (Nov 23, 2023):

are you on newest cli version 2.0.4?

@alextran1502 commented on GitHub (Nov 23, 2023): are you on newest cli version 2.0.4?
Author
Owner

@esmoyer commented on GitHub (Nov 23, 2023):

are you on newest cli version 2.0.4?

Yep. Even removed and reinstalled it to be sure.

@esmoyer commented on GitHub (Nov 23, 2023): > are you on newest cli version 2.0.4? Yep. Even removed and reinstalled it to be sure.
Author
Owner

@esmoyer commented on GitHub (Nov 23, 2023):

@alextran1502 is it possible to still use the old CLI tool with the 1.88.2 version? IDK why I'm struggling with the new CLI importer. I either get those errors or it'll crash my entire proxmox server. Though, maybe it's something else on my side.

@esmoyer commented on GitHub (Nov 23, 2023): @alextran1502 is it possible to still use the old CLI tool with the 1.88.2 version? IDK why I'm struggling with the new CLI importer. I either get those errors or it'll crash my entire proxmox server. Though, maybe it's something else on my side.
Author
Owner

@alextran1502 commented on GitHub (Nov 23, 2023):

@esmoyer Can you check with immich --version?

@alextran1502 commented on GitHub (Nov 23, 2023): @esmoyer Can you check with `immich --version`?
Author
Owner

@esmoyer commented on GitHub (Nov 23, 2023):

@esmoyer Can you check with immich --version?

I have...2.0.4. That's the latest, correct?

@esmoyer commented on GitHub (Nov 23, 2023): > @esmoyer Can you check with `immich --version`? I have...2.0.4. That's the latest, correct?
Author
Owner

@dirtypuddin commented on GitHub (Nov 24, 2023):

I had same error when trying to upload large amount of files. splitting it up worked for me. it failed when uploading above ∼10000 files from what I experienced.

Not work for me. Even when I upload a folder with only one pic, I experienced the same bug too. Besides, when I use the command Immich upload xx.jpg,the response is that the pic doesn’t exist. I guess maybe it’s about the detection method?

@dirtypuddin commented on GitHub (Nov 24, 2023): > I had same error when trying to upload large amount of files. splitting it up worked for me. it failed when uploading above ∼10000 files from what I experienced. Not work for me. Even when I upload a folder with only one pic, I experienced the same bug too. Besides, when I use the command `Immich upload xx.jpg`,the response is that the pic doesn’t exist. I guess maybe it’s about the detection method?
Author
Owner

@alextran1502 commented on GitHub (Nov 24, 2023):

@etnoy holla, do you have any idea on this issue?

@alextran1502 commented on GitHub (Nov 24, 2023): @etnoy holla, do you have any idea on this issue?
Author
Owner

@fengci commented on GitHub (Nov 27, 2023):

Too many files were selected at once. It works fine when I upload folders in separate batches.

@fengci commented on GitHub (Nov 27, 2023): Too many files were selected at once. It works fine when I upload folders in separate batches.
Author
Owner

@tomikonieczny commented on GitHub (Nov 27, 2023):

Too many files were selected at once. It works fine when I upload folders in separate batches.

the same for me

@tomikonieczny commented on GitHub (Nov 27, 2023): > Too many files were selected at once. It works fine when I upload folders in separate batches. the same for me
Author
Owner

@etnoy commented on GitHub (Nov 27, 2023):

Interesting. Roughly how many files do you have in your photo collection?

Try increasing the Linux ulimit and see if that workaround fixes it: https://www.baeldung.com/linux/error-too-many-open-files

@etnoy commented on GitHub (Nov 27, 2023): Interesting. Roughly how many files do you have in your photo collection? Try increasing the Linux ulimit and see if that workaround fixes it: https://www.baeldung.com/linux/error-too-many-open-files
Author
Owner

@EduardTheThird commented on GitHub (Nov 27, 2023):

The same issue on Windows 11 and Ubuntu 23.04.
Splitting the imports to +-5000 works fine, but this is painful for a new install.

@EduardTheThird commented on GitHub (Nov 27, 2023): The same issue on Windows 11 and Ubuntu 23.04. Splitting the imports to +-5000 works fine, but this is painful for a new install.
Author
Owner

@etnoy commented on GitHub (Nov 27, 2023):

It would appear this is a bug in the CLI. For the moment you can use the legacy CLI until we push out a fix.

@alextran1502: It might be that we do stat() on too many files at once

@etnoy commented on GitHub (Nov 27, 2023): It would appear this is a bug in the CLI. For the moment you can use the legacy CLI until we push out a fix. @alextran1502: It might be that we do stat() on too many files at once
Author
Owner

@jareddr commented on GitHub (Nov 28, 2023):

Just popping in to say that I'm having the same issue when trying to import my Google Takeout photos dump which is apparently >100 GB.

OS: Windows 11
Immich CLI Version: 2.0.4

@jareddr commented on GitHub (Nov 28, 2023): Just popping in to say that I'm having the same issue when trying to import my Google Takeout photos dump which is apparently >100 GB. OS: Windows 11 Immich CLI Version: 2.0.4
Author
Owner

@alextran1502 commented on GitHub (Nov 29, 2023):

@jareddr At the moment, I would redirect you over to use immich-go for this task

@alextran1502 commented on GitHub (Nov 29, 2023): @jareddr At the moment, I would redirect you over to use [immich-go](https://github.com/simulot/immich-go) for this task
Author
Owner

@jareddr commented on GitHub (Nov 29, 2023):

Thanks, I wasn’t aware of that client.

I ended up just writing a short script that ran this immich client on each
of the sub directories in my Takeout folder and that did the trick.

On Tue, Nov 28, 2023 at 8:20 PM Alex @.***> wrote:

@jareddr https://github.com/jareddr At the moment, I would redirect you
over to use immich-go https://github.com/simulot/immich-go for this task


Reply to this email directly, view it on GitHub
https://github.com/immich-app/immich/issues/5271#issuecomment-1831192505,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAFHZ4YMFIDXKQR6DXSIUV3YG2ZYBAVCNFSM6AAAAAA7W6HNKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRGE4TENJQGU
.
You are receiving this because you were mentioned.Message ID:
@.***>

@jareddr commented on GitHub (Nov 29, 2023): Thanks, I wasn’t aware of that client. I ended up just writing a short script that ran this immich client on each of the sub directories in my Takeout folder and that did the trick. On Tue, Nov 28, 2023 at 8:20 PM Alex ***@***.***> wrote: > @jareddr <https://github.com/jareddr> At the moment, I would redirect you > over to use immich-go <https://github.com/simulot/immich-go> for this task > > — > Reply to this email directly, view it on GitHub > <https://github.com/immich-app/immich/issues/5271#issuecomment-1831192505>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AAFHZ4YMFIDXKQR6DXSIUV3YG2ZYBAVCNFSM6AAAAAA7W6HNKSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRGE4TENJQGU> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@JoePassanante commented on GitHub (Nov 29, 2023):

Hacky workaround...

for /D %d in (*) do immich upload --skip-hash -r "%d"

It finds all the "final" subdirectories and runs the command there. This will still break if you have > max open files in a singular directory. Also assumes all your images are in the leaf-node directories.

This works well if you are recovering a different immich instance.

@JoePassanante commented on GitHub (Nov 29, 2023): Hacky workaround... ``` for /D %d in (*) do immich upload --skip-hash -r "%d" ``` It finds all the "final" subdirectories and runs the command there. This will still break if you have > max open files in a singular directory. Also assumes all your images are in the leaf-node directories. This works well if you are recovering a different immich instance.
Author
Owner

@daymr commented on GitHub (Dec 8, 2023):

Hacky workaround...

for /D %d in (*) do immich upload --skip-hash -r "%d"

It finds all the "final" subdirectories and runs the command there. This will still break if you have > max open files in a singular directory. Also assumes all your images are in the leaf-node directories.

This works well if you are recovering a different immich instance.

@JoePassanante Thank you for this! This allowed me to import 181,713 files flawlessly

@daymr commented on GitHub (Dec 8, 2023): > Hacky workaround... > > ``` > for /D %d in (*) do immich upload --skip-hash -r "%d" > ``` > > It finds all the "final" subdirectories and runs the command there. This will still break if you have > max open files in a singular directory. Also assumes all your images are in the leaf-node directories. > > This works well if you are recovering a different immich instance. @JoePassanante Thank you for this! This allowed me to import 181,713 files flawlessly
Author
Owner

@etnoy commented on GitHub (Dec 19, 2023):

I have created a PR that hopefully resolves the issue but I need input from you to test if this works. Anybody want to throw a large upload at it to see what happens?: #5841

@etnoy commented on GitHub (Dec 19, 2023): I have created a PR that hopefully resolves the issue but I need input from you to test if this works. Anybody want to throw a large upload at it to see what happens?: #5841
Author
Owner

@Moosbee commented on GitHub (Dec 31, 2023):

I use the newest version downloadet from npm and it still fails.

PS M:\Bilder\Familie> immich upload --recursive -a ./
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, open 'M:\Bilder\Familie\2010_06_01_Hallein-Keltendorf\Foto_MagdalenaII 219.jpg'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4066,
  code: 'EMFILE',
  syscall: 'open',
  path: 'M:\\Bilder\\Familie\\2010_06_01_Hallein-Keltendorf\\Foto_MagdalenaII 219.jpg'
}

Node.js v18.17.1
PS M:\Bilder\Familie> immich --version
2.0.5

I am on Windows 10 use powershell and M is a smb(TrueNAS) server

@Moosbee commented on GitHub (Dec 31, 2023): I use the newest version downloadet from npm and it still fails. ``` PS M:\Bilder\Familie> immich upload --recursive -a ./ node:events:492 throw er; // Unhandled 'error' event ^ Error: EMFILE: too many open files, open 'M:\Bilder\Familie\2010_06_01_Hallein-Keltendorf\Foto_MagdalenaII 219.jpg' Emitted 'error' event on ReadStream instance at: at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { errno: -4066, code: 'EMFILE', syscall: 'open', path: 'M:\\Bilder\\Familie\\2010_06_01_Hallein-Keltendorf\\Foto_MagdalenaII 219.jpg' } Node.js v18.17.1 PS M:\Bilder\Familie> immich --version 2.0.5 ``` I am on Windows 10 use powershell and `M` is a smb(TrueNAS) server
Author
Owner

@etnoy commented on GitHub (Dec 31, 2023):

I use the newest version downloadet from npm and it still fails.

PS M:\Bilder\Familie> immich upload --recursive -a ./
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, open 'M:\Bilder\Familie\2010_06_01_Hallein-Keltendorf\Foto_MagdalenaII 219.jpg'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4066,
  code: 'EMFILE',
  syscall: 'open',
  path: 'M:\\Bilder\\Familie\\2010_06_01_Hallein-Keltendorf\\Foto_MagdalenaII 219.jpg'
}

Node.js v18.17.1
PS M:\Bilder\Familie> immich --version
2.0.5

I am on Windows 10 use powershell and M is a smb(TrueNAS) server

The fix is in git but it hasn't been released yet. Follow the instructions in the CLI folder of the main repo to build from source.

@etnoy commented on GitHub (Dec 31, 2023): > I use the newest version downloadet from npm and it still fails. > > ``` > PS M:\Bilder\Familie> immich upload --recursive -a ./ > node:events:492 > throw er; // Unhandled 'error' event > ^ > > Error: EMFILE: too many open files, open 'M:\Bilder\Familie\2010_06_01_Hallein-Keltendorf\Foto_MagdalenaII 219.jpg' > Emitted 'error' event on ReadStream instance at: > at emitErrorNT (node:internal/streams/destroy:151:8) > at emitErrorCloseNT (node:internal/streams/destroy:116:3) > at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { > errno: -4066, > code: 'EMFILE', > syscall: 'open', > path: 'M:\\Bilder\\Familie\\2010_06_01_Hallein-Keltendorf\\Foto_MagdalenaII 219.jpg' > } > > Node.js v18.17.1 > PS M:\Bilder\Familie> immich --version > 2.0.5 > ``` > > I am on Windows 10 use powershell and `M` is a smb(TrueNAS) server The fix is in git but it hasn't been released yet. Follow the instructions in the CLI folder of the main repo to build from source.
Author
Owner

@dejuknow commented on GitHub (Dec 31, 2023):

Building from source didn't fix it for me. Still get the "EMFILE: too many open files error" :(

@dejuknow commented on GitHub (Dec 31, 2023): Building from source didn't fix it for me. Still get the "EMFILE: too many open files error" :(
Author
Owner

@etnoy commented on GitHub (Dec 31, 2023):

Building from source didn't fix it for me. Still get the "EMFILE: too many open files error" :(

You need to uninstall the old version first

@etnoy commented on GitHub (Dec 31, 2023): > Building from source didn't fix it for me. Still get the "EMFILE: too many open files error" :( You need to uninstall the old version first
Author
Owner

@dejuknow commented on GitHub (Dec 31, 2023):

I did. I also manually bumped the version before building and checked the version command to ensure I was running my local build.

@dejuknow commented on GitHub (Dec 31, 2023): I did. I also manually bumped the version before building and checked the version command to ensure I was running my local build.
Author
Owner

@etnoy commented on GitHub (Dec 31, 2023):

I did. I also manually bumped the version before building and checked the version command to ensure I was running my local build.

It's a hard issue for me to validate the fix for, thanks for letting me know. How many files? What platform are you on, and what node version?

@etnoy commented on GitHub (Dec 31, 2023): > I did. I also manually bumped the version before building and checked the version command to ensure I was running my local build. It's a hard issue for me to validate the fix for, thanks for letting me know. How many files? What platform are you on, and what node version?
Author
Owner

@dejuknow commented on GitHub (Jan 1, 2024):

About 30k files, 1460 folders. Synology DS218+ (I'm running the CLI from my NAS). node v14.21.2.

@dejuknow commented on GitHub (Jan 1, 2024): About 30k files, 1460 folders. Synology DS218+ (I'm running the CLI from my NAS). node v14.21.2.
Author
Owner

@Moosbee commented on GitHub (Jan 1, 2024):

I have about 755 folders(42189 assets), I also tryed compiling from source and it didn't work either.

@Moosbee commented on GitHub (Jan 1, 2024): I have about 755 folders(42189 assets), I also tryed compiling from source and it didn't work either.
Author
Owner

@Moosbee commented on GitHub (Jan 2, 2024):

From the graceful-fs readme

#Sync methods

This module cannot intercept or handle EMFILE or ENFILE errors from sync methods. If you use sync methods which open file descriptors then you are responsible for dealing with any errors.

This is a known limitation, not a bug.

as far as I can see the problem is this.assetData = this.getReadStream(this.path); in assets.ts wich uses internaly return fs.createReadStream(path);, I do not know if it is a sync call, but considering there is no await, it looks like one.

@Moosbee commented on GitHub (Jan 2, 2024): From the graceful-fs readme > > #Sync methods > > This module cannot intercept or handle EMFILE or ENFILE errors from sync methods. If you use sync methods which open file descriptors then you are responsible for dealing with any errors. > > This is a known limitation, not a bug. ~~as far as I can see~~ the problem is `this.assetData = this.getReadStream(this.path);` in assets.ts wich uses internaly `return fs.createReadStream(path);`, I do not know if it is a sync call, but considering there is no await, it looks like one.
Author
Owner

@etnoy commented on GitHub (Jan 2, 2024):

From the graceful-fs readme

#Sync methods
This module cannot intercept or handle EMFILE or ENFILE errors from sync methods. If you use sync methods which open file descriptors then you are responsible for dealing with any errors.
This is a known limitation, not a bug.

as far as I can see the problem is this.assetData = this.getReadStream(this.path); in assets.ts wich uses internaly return fs.createReadStream(path);, I do not know if it is a sync call, but considering there is no await, it looks like one.

Thanks for your detective work here. I'll try to see if I can refactor this code.

@etnoy commented on GitHub (Jan 2, 2024): > From the graceful-fs readme > > > #Sync methods > > This module cannot intercept or handle EMFILE or ENFILE errors from sync methods. If you use sync methods which open file descriptors then you are responsible for dealing with any errors. > > This is a known limitation, not a bug. > > ~as far as I can see~ the problem is `this.assetData = this.getReadStream(this.path);` in assets.ts wich uses internaly `return fs.createReadStream(path);`, I do not know if it is a sync call, but considering there is no await, it looks like one. Thanks for your detective work here. I'll try to see if I can refactor this code.
Author
Owner

@jrasm91 commented on GitHub (Jan 2, 2024):

The issue is a for loop that opens file handles before they are uploaded.

@jrasm91 commented on GitHub (Jan 2, 2024): The issue is a for loop that opens file handles before they are uploaded.
Author
Owner

@etnoy commented on GitHub (Jan 2, 2024):

@dejuknow @Moosbee are you able to test Jason's PR and see if it works better? https://github.com/immich-app/immich/pull/6110

@etnoy commented on GitHub (Jan 2, 2024): @dejuknow @Moosbee are you able to test Jason's PR and see if it works better? https://github.com/immich-app/immich/pull/6110
Author
Owner

@dejuknow commented on GitHub (Jan 2, 2024):

That fixed it for me! Thx @jrasm91!

@dejuknow commented on GitHub (Jan 2, 2024): That fixed it for me! Thx @jrasm91!
Author
Owner

@jrasm91 commented on GitHub (Jan 2, 2024):

2.0.6 has been released with a fix for this.

@jrasm91 commented on GitHub (Jan 2, 2024): 2.0.6 has been released with a fix for this.
Author
Owner

@ehcheng commented on GitHub (Apr 7, 2024):

I'm having this same issue, but when scanning for new files on an external library. I split some of the files into another folder / library, and scanning that library worked, but I have hundreds of thousands of images in the main one that is failing.

immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Unable to run job handler (library/library-refresh): Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc'
immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc'

Server
OS X Sonoma 14.4.1

IMMICH Server Version
[v1.101.0]

@ehcheng commented on GitHub (Apr 7, 2024): I'm having this same issue, but when scanning for new files on an external library. I split some of the files into another folder / library, and scanning that library worked, but I have hundreds of thousands of images in the main one that is failing. immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Unable to run job handler (library/library-refresh): Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc' immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc' Server OS X Sonoma 14.4.1 IMMICH Server Version [v1.101.0]
Author
Owner

@etnoy commented on GitHub (Apr 7, 2024):

I'm having this same issue, but when scanning for new files on an external library. I split some of the files into another folder / library, and scanning that library worked, but I have hundreds of thousands of images in the main one that is failing.

immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Unable to run job handler (library/library-refresh): Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc' immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc'

Server OS X Sonoma 14.4.1

IMMICH Server Version [v1.101.0]

I've never seen this before. Please file an issue

@etnoy commented on GitHub (Apr 7, 2024): > I'm having this same issue, but when scanning for new files on an external library. I split some of the files into another folder / library, and scanning that library worked, but I have hundreds of thousands of images in the main one that is failing. > > immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Unable to run job handler (library/library-refresh): Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc' immich_microservices | [Nest] 7 - 04/07/2024, 4:57:29 AM ERROR [JobService] Error: EMFILE: too many open files, scandir '/mnt/media/cold/abc' > > Server OS X Sonoma 14.4.1 > > IMMICH Server Version [v1.101.0] I've never seen this before. Please file an issue
Author
Owner

@ehcheng commented on GitHub (Apr 7, 2024):

I'm having this same issue, but when scanning for new files on an external library... [snip]

I've never seen this before. Please file an issue

Thank you for the guidance. Done. https://github.com/immich-app/immich/issues/8592

@ehcheng commented on GitHub (Apr 7, 2024): > > I'm having this same issue, but when scanning for new files on an external library... [snip] > > I've never seen this before. Please file an issue Thank you for the guidance. Done. https://github.com/immich-app/immich/issues/8592
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1680