[Bug]: Crash uploading a file > 4 GiB #549

Closed
opened 2026-04-24 23:12:37 +02:00 by adam · 1 comment
Owner

Originally created by @MM2-0 on GitHub (Jul 27, 2022).

Describe the issue

Using the web interface to upload a file larger than 4 GiB will crash the server.

/server/libs/njodb/index.js:103
         throw error;
         ^
 
 RangeError [ERR_OUT_OF_RANGE]: The value of "length" is out of range. It must be >= 0 && <= 4294967296. Received 4_676_987_052
     at validateOffset (node:buffer:113:3)
     at Function.concat (node:buffer:550:5)
     at getBuffer (/server/libs/expressFileupload/memHandler.js:17:34)
     at complete (/server/libs/expressFileupload/memHandler.js:37:14)
     at FileStream.<anonymous> (/server/libs/expressFileupload/processMultipart.js:118:17)
     at FileStream.emit (node:events:539:35)
     at endReadableNT (node:internal/streams/readable:1345:12)
     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
   code: 'ERR_OUT_OF_RANGE'
 }

Copying the file manually to the library directory works fine as a workaround.

I realize that 4 GiB is quite large and that it would probably be a good idea to split that file into multiple parts (or use better encoding settings). I think it'd be fine if the web interface just displayed an error message when a user attempts to upload a file that large.

Steps to reproduce the issue

  1. Use the web interface to upload a new audiobook
  2. Select a file larger than 4294967296 bytes
  3. The server will crash during the upload (not immediately, presumably after 4294967296 bytes have been uploaded) and the upload fails (no file exists at the target location)

Audiobookshelf version

v2.1.0

How are you running audiobookshelf?

Docker

Originally created by @MM2-0 on GitHub (Jul 27, 2022). ### Describe the issue Using the web interface to upload a file larger than 4 GiB will crash the server. ``` /server/libs/njodb/index.js:103 throw error; ^ RangeError [ERR_OUT_OF_RANGE]: The value of "length" is out of range. It must be >= 0 && <= 4294967296. Received 4_676_987_052 at validateOffset (node:buffer:113:3) at Function.concat (node:buffer:550:5) at getBuffer (/server/libs/expressFileupload/memHandler.js:17:34) at complete (/server/libs/expressFileupload/memHandler.js:37:14) at FileStream.<anonymous> (/server/libs/expressFileupload/processMultipart.js:118:17) at FileStream.emit (node:events:539:35) at endReadableNT (node:internal/streams/readable:1345:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'ERR_OUT_OF_RANGE' } ``` Copying the file manually to the library directory works fine as a workaround. I realize that 4 GiB is quite large and that it would probably be a good idea to split that file into multiple parts (or use better encoding settings). I think it'd be fine if the web interface just displayed an error message when a user attempts to upload a file that large. ### Steps to reproduce the issue 1. Use the web interface to upload a new audiobook 2. Select a file larger than 4294967296 bytes 3. The server will crash during the upload (not immediately, presumably after 4294967296 bytes have been uploaded) and the upload fails (no file exists at the target location) ### Audiobookshelf version v2.1.0 ### How are you running audiobookshelf? Docker
adam added the bug label 2026-04-24 23:12:37 +02:00
adam closed this issue 2026-04-24 23:12:37 +02:00
Author
Owner

@advplyr commented on GitHub (Jun 11, 2023):

Fixed in v2.2.23

@advplyr commented on GitHub (Jun 11, 2023): Fixed in [v2.2.23](https://github.com/advplyr/audiobookshelf/releases/tag/v2.2.23)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#549