[BUG] Safari/Firefox on MacOS/IOS downloads end in Premature close #1095

Closed
opened 2026-02-05 00:27:09 +03:00 by OVERLORD · 10 comments
Owner

Originally created by @Y0ngg4n on GitHub (Jul 13, 2023).

The bug

Everytime i download something via Safari or Firefox in MacOS or IOS i get this error:

[Nest] 7  - 07/13/2023, 9:43:03 AM   ERROR [ExpressAdapter] Premature close
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
    at new NodeError (node:internal/errors:399:5)
    at ServerResponse.onclose (node:internal/streams/end-of-stream:154:30)
    at ServerResponse.emit (node:events:525:35)
    at emitCloseNT (node:_http_server:984:10)
    at Socket.onServerResponseClose (node:_http_server:277:5)
    at Socket.emit (node:events:525:35)
    at TCP.<anonymous> (node:net:322:12)

The OS that Immich Server is running on

K8S + Traefik

Version of Immich Server

v1.66.1

Version of Immich Mobile App

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

Using the Helm Chart

Your .env content

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: immich
  namespace: storage
spec:
  interval: 5m
  timeout: 60m
  chart:
    spec:
      chart: immich
      version: ">= 0.1.1"
      sourceRef:
        kind: HelmRepository
        name: immich
        namespace: flux-system
      interval: 1m
  values:
    image:
      tag: v1.66.1 # {"$imagepolicy": "flux-system:immich:tag"}
    immich:
      persistence:
        library:
          existingClaim: immich-pvc
    env:
      REDIS_HOSTNAME: redis-master.redis
      REDIS_PORT: "6379"
      REDIS_USERNAME: default
      REDIS_PASSWORD:
        valueFrom:
          secretKeyRef:
            name: immich-secret
            key: redis
      DB_HOSTNAME: kubegres.kubegres-system
      DB_USERNAME: immich
      DB_DATABASE_NAME: immich
      DB_PASSWORD:
        valueFrom:
          secretKeyRef:
            name: immich-secret
            key: postgresqlPassword
    proxy:
      ingress:
        main:
          enabled: true
          annotations:
            cert-manager.io/cluster-issuer: letsencrypt-prod
          hosts:
            - host: pictures.example.com
              paths:
                - path: "/"
          tls:
            - hosts:
                - pictures.example.com
              secretName: immich-obco-tls
    typesense:
      enabled: true
      env:
        TYPESENSE_DATA_DIR: /cache
        TYPESENSE_API_KEY: REDACTED
      persistence:
        cache:
          enabled: true
          accessMode: ReadWriteMany
          size: 1Gi
          existingClaim: typesense-pvc
    machine-learning:
      resources:
        limits:
          cpu: 200m
          memory: 500Mi
      probes:
        liveness:
          spec:
            enabled: false
        readiness:
          spec:
            enabled: false
        startup:
          spec:
            enable: false


### Reproduction steps

```bash
1. Create a album with fotos and videos. Try to download the whole album.

Additional information

No response

Originally created by @Y0ngg4n on GitHub (Jul 13, 2023). ### The bug Everytime i download something via Safari or Firefox in MacOS or IOS i get this error: ``` [Nest] 7 - 07/13/2023, 9:43:03 AM ERROR [ExpressAdapter] Premature close Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close at new NodeError (node:internal/errors:399:5) at ServerResponse.onclose (node:internal/streams/end-of-stream:154:30) at ServerResponse.emit (node:events:525:35) at emitCloseNT (node:_http_server:984:10) at Socket.onServerResponseClose (node:_http_server:277:5) at Socket.emit (node:events:525:35) at TCP.<anonymous> (node:net:322:12) ``` ### The OS that Immich Server is running on K8S + Traefik ### Version of Immich Server v1.66.1 ### Version of Immich Mobile App - ### Platform with the issue - [X] Server - [X] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML Using the Helm Chart ``` ### Your .env content ```Shell apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: immich namespace: storage spec: interval: 5m timeout: 60m chart: spec: chart: immich version: ">= 0.1.1" sourceRef: kind: HelmRepository name: immich namespace: flux-system interval: 1m values: image: tag: v1.66.1 # {"$imagepolicy": "flux-system:immich:tag"} immich: persistence: library: existingClaim: immich-pvc env: REDIS_HOSTNAME: redis-master.redis REDIS_PORT: "6379" REDIS_USERNAME: default REDIS_PASSWORD: valueFrom: secretKeyRef: name: immich-secret key: redis DB_HOSTNAME: kubegres.kubegres-system DB_USERNAME: immich DB_DATABASE_NAME: immich DB_PASSWORD: valueFrom: secretKeyRef: name: immich-secret key: postgresqlPassword proxy: ingress: main: enabled: true annotations: cert-manager.io/cluster-issuer: letsencrypt-prod hosts: - host: pictures.example.com paths: - path: "/" tls: - hosts: - pictures.example.com secretName: immich-obco-tls typesense: enabled: true env: TYPESENSE_DATA_DIR: /cache TYPESENSE_API_KEY: REDACTED persistence: cache: enabled: true accessMode: ReadWriteMany size: 1Gi existingClaim: typesense-pvc machine-learning: resources: limits: cpu: 200m memory: 500Mi probes: liveness: spec: enabled: false readiness: spec: enabled: false startup: spec: enable: false ``` ``` ### Reproduction steps ```bash 1. Create a album with fotos and videos. Try to download the whole album. ``` ### Additional information _No response_
Author
Owner

@bo0tzz commented on GitHub (Jul 13, 2023):

Is the download failing, or are you just seeing this error in the logs alongside a succesful download? This error usually happens when you stop viewing a video in the web UI before it's fully loaded.

@bo0tzz commented on GitHub (Jul 13, 2023): Is the download failing, or are you just seeing this error in the logs alongside a succesful download? This error usually happens when you stop viewing a video in the web UI before it's fully loaded.
Author
Owner

@Y0ngg4n commented on GitHub (Jul 13, 2023):

@bo0tzz the download is failing. I cancels the download in the web ui and says some kind of error message.

@Y0ngg4n commented on GitHub (Jul 13, 2023): @bo0tzz the download is failing. I cancels the download in the web ui and says some kind of error message.
Author
Owner

@bo0tzz commented on GitHub (Jul 13, 2023):

Can you share the error message that is displayed, and also see if there's other error messages in the browser devtools' console or network tabs?

@bo0tzz commented on GitHub (Jul 13, 2023): Can you share the error message that is displayed, and also see if there's other error messages in the browser devtools' console or network tabs?
Author
Owner

@Y0ngg4n commented on GitHub (Jul 13, 2023):

@bo0tzz it says unable to download files. This is the console log:

[handleError]: Unable to download files 
Object { message: "Network Error", name: "AxiosError", code: "ERR_NETWORK", config: {…}, request: XMLHttpRequest, response: XMLHttpRequest, stack: "" }
​
code: "ERR_NETWORK"
​
config: Object { timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", … }
​​
adapter: function xe(V)
​​
data: '{"assetIds":["898be35b-e02a-4d49-99ec-db8f0dc61c56","b281ff76-37f9-45b2-ac41-3631f9a7f947","2488dd8f-3d0f-439f-a706-376e09ced1ff","56c8253f-ac98-4e43-a8a2-feb86af1999e","761f471f-3757-4881-b8e8-f9743775c676","e1e8d518-3976-4e3d-a86b-b606f81c91dc","3c30c5f0-1135-406a-8d8d-1a73c4e7a25d","ba1bc662-8c06-4845-b2d3-32ff13e9979f","d104c2ee-e437-4e5a-8bf8-1a90b4fbe0c9","25d57212-da33-4486-8dae-9f76ce5d2e49","4bb68aeb-2190-4ef1-83f5-1b0740d7893e","2e18a057-6c72-4af7-b7e5-e44981840442","e1f27016-bfab-4fdb-b981-c22dcc865504","da6333f3-145f-47e5-98e9-8648fdd73efe","2f8c4481-644a-495b-8b7e-ecc1ce336f22","1c463619-41a2-47c4-b487-e31e8e98bcaa","3ab0eb3f-fa7c-45cb-977d-0974f992790e","72499262-06ca-4c36-ace0-c52dc956ff43","6d58f90a-eed3-40af-a2bb-39219edfaffa","bbb15df3-492f-40b0-920e-885906e388f3","e660ac7c-06a9-476d-9774-9009fdaec0c1","b05a512c-5290-44b5-9441-ee7ece804888","b6ca5f5c-f89b-4de0-a20f-716de3ff761d","53ba2798-bb5a-4ea4-977d-002af0a16687","b6d59f7a-b7c0-4392-b90f-26b575c29bf6"]}'
​​
env: Object { FormData: null }
​​
headers: Object { Accept: "application/json, text/plain, */*", "Content-Type": "application/json" }
​​
maxBodyLength: -1
​​
maxContentLength: -1
​​
method: "post"
​​
onDownloadProgress: function onDownloadProgress(h)
​​
responseType: "blob"
​​
timeout: 0
​​
transformRequest: Array [ transformRequest(e, a)
 ]
​​
transformResponse: Array [ transformResponse(e)
 ]
​​
transitional: Object { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false }
​​
url: "/api/asset/download?key=VHtIHpJKHFc3trypkMl1bGyHh8Ddwpv0GOjoECJffkDvAQhNNe3XP38DPmPRq86khOw"
​​
validateStatus: function validateStatus(e)
​​
xsrfCookieName: "XSRF-TOKEN"
​​
xsrfHeaderName: "X-XSRF-TOKEN"
​​
<prototype>: Object { … }
​
message: "Network Error"
​
name: "AxiosError"
​
request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​
response: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … }
​
stack: ""
​
<prototype>: Object { constructor: Z(t, e, a, s, r), toJSON: toJSON()
, stack: "", … }
​​
constructor: function Z(t, e, a, s, r)
​​
isAxiosError: true
​​
stack: ""
​​
toJSON: function toJSON()​​
<prototype>: Error.prototype { stack: "", … }
handle-error.7740aa47.js:1:467
    Immutable 2
@Y0ngg4n commented on GitHub (Jul 13, 2023): @bo0tzz it says unable to download files. This is the console log: ``` [handleError]: Unable to download files Object { message: "Network Error", name: "AxiosError", code: "ERR_NETWORK", config: {…}, request: XMLHttpRequest, response: XMLHttpRequest, stack: "" } ​ code: "ERR_NETWORK" ​ config: Object { timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", … } ​​ adapter: function xe(V) ​​ data: '{"assetIds":["898be35b-e02a-4d49-99ec-db8f0dc61c56","b281ff76-37f9-45b2-ac41-3631f9a7f947","2488dd8f-3d0f-439f-a706-376e09ced1ff","56c8253f-ac98-4e43-a8a2-feb86af1999e","761f471f-3757-4881-b8e8-f9743775c676","e1e8d518-3976-4e3d-a86b-b606f81c91dc","3c30c5f0-1135-406a-8d8d-1a73c4e7a25d","ba1bc662-8c06-4845-b2d3-32ff13e9979f","d104c2ee-e437-4e5a-8bf8-1a90b4fbe0c9","25d57212-da33-4486-8dae-9f76ce5d2e49","4bb68aeb-2190-4ef1-83f5-1b0740d7893e","2e18a057-6c72-4af7-b7e5-e44981840442","e1f27016-bfab-4fdb-b981-c22dcc865504","da6333f3-145f-47e5-98e9-8648fdd73efe","2f8c4481-644a-495b-8b7e-ecc1ce336f22","1c463619-41a2-47c4-b487-e31e8e98bcaa","3ab0eb3f-fa7c-45cb-977d-0974f992790e","72499262-06ca-4c36-ace0-c52dc956ff43","6d58f90a-eed3-40af-a2bb-39219edfaffa","bbb15df3-492f-40b0-920e-885906e388f3","e660ac7c-06a9-476d-9774-9009fdaec0c1","b05a512c-5290-44b5-9441-ee7ece804888","b6ca5f5c-f89b-4de0-a20f-716de3ff761d","53ba2798-bb5a-4ea4-977d-002af0a16687","b6d59f7a-b7c0-4392-b90f-26b575c29bf6"]}' ​​ env: Object { FormData: null } ​​ headers: Object { Accept: "application/json, text/plain, */*", "Content-Type": "application/json" } ​​ maxBodyLength: -1 ​​ maxContentLength: -1 ​​ method: "post" ​​ onDownloadProgress: function onDownloadProgress(h) ​​ responseType: "blob" ​​ timeout: 0 ​​ transformRequest: Array [ transformRequest(e, a) ] ​​ transformResponse: Array [ transformResponse(e) ] ​​ transitional: Object { silentJSONParsing: true, forcedJSONParsing: true, clarifyTimeoutError: false } ​​ url: "/api/asset/download?key=VHtIHpJKHFc3trypkMl1bGyHh8Ddwpv0GOjoECJffkDvAQhNNe3XP38DPmPRq86khOw" ​​ validateStatus: function validateStatus(e) ​​ xsrfCookieName: "XSRF-TOKEN" ​​ xsrfHeaderName: "X-XSRF-TOKEN" ​​ <prototype>: Object { … } ​ message: "Network Error" ​ name: "AxiosError" ​ request: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … } ​ response: XMLHttpRequest { readyState: 4, timeout: 0, withCredentials: false, … } ​ stack: "" ​ <prototype>: Object { constructor: Z(t, e, a, s, r), toJSON: toJSON() , stack: "", … } ​​ constructor: function Z(t, e, a, s, r) ​​ isAxiosError: true ​​ stack: "" ​​ toJSON: function toJSON()​​ <prototype>: Error.prototype { stack: "", … } handle-error.7740aa47.js:1:467 Immutable 2 ```
Author
Owner

@Y0ngg4n commented on GitHub (Jul 13, 2023):

maybe it is correlated to missing storage space. because after i deleted some files, it worked. But it should definitely say "hey you don´t have enough storage space"

@Y0ngg4n commented on GitHub (Jul 13, 2023): maybe it is correlated to missing storage space. because after i deleted some files, it worked. But it should definitely say "hey you don´t have enough storage space"
Author
Owner

@bo0tzz commented on GitHub (Jul 13, 2023):

It seems quite likely that low disk space would cause this kind of problem. I don't know if there is a clear error for us to handle there though. @jrasm91 thoughts?

@bo0tzz commented on GitHub (Jul 13, 2023): It seems quite likely that low disk space would cause this kind of problem. I don't know if there is a clear error for us to handle there though. @jrasm91 thoughts?
Author
Owner

@jrasm91 commented on GitHub (Jul 13, 2023):

That's an interesting situation. I think we'd have to test it to see how the app responds. It is interesting that the error message uses the code ERR_NETWORK, which makes me think the network was in play, but maybe the request is just dropped due to lack of space and that results in that code. Will require further investigation, but I don't think anyone has done tests with immich running low on disk space.

@jrasm91 commented on GitHub (Jul 13, 2023): That's an interesting situation. I think we'd have to test it to see how the app responds. It is interesting that the error message uses the code `ERR_NETWORK`, which makes me think the network was in play, but maybe the request is just dropped due to lack of space and that results in that code. Will require further investigation, but I don't think anyone has done tests with immich running low on disk space.
Author
Owner

@Y0ngg4n commented on GitHub (Jul 13, 2023):

@bo0tzz @jrasm91 i think it would be good to display the size of the file at least when downloading so you can check by yourself.
Ah sorry maybe i described it wrong. if the client that is downloading is low on disk space it does not work.
I don´t know if it is possible with browser permissions to check for available disk space but, displaying the size of the zip and changing the message to something like this:
Unable to download files. Check if you have enough disk space. Would be fine as first step. The second step would be to evaluate if disk space can be checked client side.

@Y0ngg4n commented on GitHub (Jul 13, 2023): @bo0tzz @jrasm91 i think it would be good to display the size of the file at least when downloading so you can check by yourself. Ah sorry maybe i described it wrong. if the client that is downloading is low on disk space it does not work. I don´t know if it is possible with browser permissions to check for available disk space but, displaying the size of the zip and changing the message to something like this: `Unable to download files. Check if you have enough disk space.` Would be fine as first step. The second step would be to evaluate if disk space can be checked client side.
Author
Owner

@bo0tzz commented on GitHub (Jul 14, 2023):

I don't think we get any meaningful errors from the browser if the client's disk is full, as indicated by the general "network error" you were getting in the console.

@bo0tzz commented on GitHub (Jul 14, 2023): I don't think we get any meaningful errors from the browser if the client's disk is full, as indicated by the general "network error" you were getting in the console.
Author
Owner

@Y0ngg4n commented on GitHub (Jul 14, 2023):

@bo0tzz but would be nice to at least display the size of the download

@Y0ngg4n commented on GitHub (Jul 14, 2023): @bo0tzz but would be nice to at least display the size of the download
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#1095