silverwind / droppy

**ARCHIVED** Self-hosted file storage
BSD 2-Clause "Simplified" License
1.62k stars 195 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'size' of undefined when running droppy in a big directory #362

Closed szmktk closed 6 years ago

szmktk commented 6 years ago

I have a collection of files (6.2 G total, some of them small, the output of tree | wc -l is 48329). When I try to start droppy with droppy start -c /srv/droppy/config -f /mnt/data/files I get the following output:

user@archRPI2:droppy $ droppy start -c /srv/droppy/config -f /mnt/data/files

           .:.
    :::  .:::::.   droppy 10.0.6 running on node 11.2.0
  ..:::..  :::     config at /srv/droppy/config
   ':::'   :::     files at /mnt/data/files
     '

2018-11-17 22:27:09 [INFO] Configuration: { listeners: [ { host: [ '0.0.0.0', '::' ], port: 8989, protocol: 'http' } ], public: false, timestamps: true, linkLength: 5, linkExtensions: false, logLevel: 2, maxFileSize: 0, updateInterval: 1000, pollingInterval: 0, keepAlive: 20000, allowFrame: false, readOnly: false, compression: true, ignorePatterns: [], watch: true }
2018-11-17 22:27:09 [INFO] Loading resources ...
2018-11-17 22:27:09 [INFO] Loading resources done
2018-11-17 22:27:09 [INFO] Listening on http://127.0.0.1:8989
2018-11-17 22:27:09 [INFO] Listening on http://192.168.50.71:8989
2018-11-17 22:27:09 [INFO] Caching files ...
(node:9054) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'size' of undefined
    at readFiles.sort.forEach.f (/usr/lib/node_modules/droppy/server/filetree.js:160:21)
    at Array.forEach (<anonymous>)
    at updateDirInCache (/usr/lib/node_modules/droppy/server/filetree.js:157:6)
    at EventEmitter.filetree.updateDir (/usr/lib/node_modules/droppy/server/filetree.js:127:3)
(node:9054) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9054) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

OS: arch linux arm hardware: raspberry pi 2 note: the files/ directory is encrypted with luks (shouldn't make any difference but it doesn't hurt to mention)

Do you have any hint on what could cause this issue and how I could help to fix it?

silverwind commented 6 years ago

I think some of your files are readable, but for some reason not not stat-able (permissions?). I added a safeguard that will display a size of 0 to avoid this error. Maybe investigate if you can find the files in question. Assuming my theory is correct, stat <filename> should fail with an error.

This fix will be available in 10.0.7 which will be available shortly.

szmktk commented 6 years ago

Many thanks for fixing the issue! As for the investigation, all I could think of was find droppy/files -type f -exec stat {} \; 1>/dev/null 2>&1 which showed no returns.

Do you have an idea of a better test? If not then feel free to resolve this issue. Many kudos for the software man, I love it.

silverwind commented 6 years ago

Other than running that command using the same user droppy runs, I don't have any better suggestions. Anyways, I'll close this, thanks for reporting.