When setting new profile avatar server returns ENOENT: no such file or directory error
Steps to reproduce:
Go to your profile
Select "Upload" under Profile Picture
Upload desired image
Expected behavior:
New avatar is set
Actual behavior:
New avatar is not set, and ENOENT error is displayed
Server Setup Information:
Version of Rocket.Chat Server: 6.2.0
Operating System: CentOS 8 Stream
Deployment Method: tar
Number of Running Instances: 1
DB Replicaset Oplog: enabled
NodeJS Version: 14.20.0
MongoDB Version: 6.0.0
Client Setup Information
Desktop App or Browser Version: 3.9.3
Operating System: Windows 11
Additional context
It seems to be the case that something in our setup is the cause, becasue we could not reproduce it with clean db. Whlie trying to figure out, what could be the case, we checked rocketchat_avatars collection for any kind of strange documents. While testing it out, we noticed, that filename that is referenced in ENOENT error is actually not in our uploads directory (we are using FileSystem storage). But there was a document in rocketchat_avatars that had an _id, of that same file in ENOENT error. After deleting this document, it was possible to upload a new avatar, but if we tried to upload avatar again after that, the ENOENT error would still occur with filename that is referenced in new _id field of that newly created document.
It is something in our setup it seems, but we can't really figure out what it is.
Relevant logs:
users.setAvatar response in DevTools:
error:
"ENOENT: no such file or directory, stat '/app/uploads/6471d00c5e94959c0f8b5ec5'"
success:
false
the same log from server:
{"level":35,"time":"2023-05-27T11:00:04.804Z","pid":1966,"hostname":"maxdev","name":"Meteor","method":"saveUserProfile","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","instanceId":"f3eba437-8864-4441-b454-24adb46f7a1c"}
{"level":35,"time":"2023-05-27T11:00:04.816Z","pid":1966,"hostname":"maxdev","name":"Meteor","method":"setUserStatus","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","instanceId":"f3eba437-8864-4441-b454-24adb46f7a1c"}
{"level":35,"time":"2023-05-27T11:00:04.821Z","pid":1966,"hostname":"maxdev","name":"Meteor","method":"setUserStatus","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","instanceId":"f3eba437-8864-4441-b454-24adb46f7a1c"}
{"level":35,"time":"2023-05-27T11:00:04.822Z","pid":1966,"hostname":"maxdev","name":"Meteor","method":"UserPresence:setDefaultStatus","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","instanceId":"f3eba437-8864-4441-b454-24adb46f7a1c"}
{"level":35,"time":"2023-05-27T11:00:04.850Z","pid":1966,"hostname":"maxdev","name":"API","method":"POST","url":"/api/v1/method.call/saveUserProfile","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","length":"174","host":"chat1.qoollo.com","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","status":200,"responseTime":48}
{"level":35,"time":"2023-05-27T11:00:05.234Z","pid":1966,"hostname":"maxdev","name":"Meteor","method":"getAvatarSuggestion","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","instanceId":"f3eba437-8864-4441-b454-24adb46f7a1c"}
{"level":40,"time":"2023-05-27T11:00:05.235Z","pid":1966,"hostname":"maxdev","name":"DeprecationWarning","section":"METHOD","msg":"getAvatarSuggestion will be deprecated in future versions of Rocket.Chat"}
{"level":35,"time":"2023-05-27T11:00:05.329Z","pid":1966,"hostname":"maxdev","name":"API","method":"GET","url":"/api/v1/users.getAvatarSuggestion","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","host":"chat1.qoollo.com","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","status":200,"responseTime":96}
{"level":35,"time":"2023-05-27T11:00:05.501Z","pid":1966,"hostname":"maxdev","name":"API","method":"POST","url":"/api/v1/users.setAvatar","userId":"sDb9zwXrujSt3DJif","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Rocket.Chat/3.9.3 Chrome/108.0.5359.215 Electron/22.3.5 Safari/537.36","length":"143763","host":"chat1.qoollo.com","referer":"https://chat1.qoollo.com/account/profile","remoteIP":"10.8.0.74","err":{"type":"Error","message":"ENOENT: no such file or directory, stat '/app/uploads/6471dbeda8f5ef1a5ca8aca7'","stack":"Error: ENOENT: no such file or directory, stat '/app/uploads/6471dbeda8f5ef1a5ca8aca7'<br> => awaited here:<br> at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at server/ufs/ufs-local.ts:72:20<br> at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40<br> => awaited here:<br> at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at app/file-upload/server/lib/FileUpload.ts:677:4<br> at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40<br> => awaited here:<br> at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at app/lib/server/functions/setUserAvatar.ts:105:15<br> at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40<br> => awaited here:<br> at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at app/api/server/v1/users.ts:250:4<br> at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40<br> => awaited here:<br> at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)<br> at app/api/server/api.ts:633:9<br> at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40","errno":-2,"code":"ENOENT","syscall":"stat","path":"/app/uploads/6471dbeda8f5ef1a5ca8aca7"},"status":400,"responseTime":24,"msg":"ENOENT: no such file or directory, stat '/app/uploads/6471dbeda8f5ef1a5ca8aca7'"}
Description:
When setting new profile avatar server returns ENOENT: no such file or directory error
Steps to reproduce:
Expected behavior:
New avatar is set
Actual behavior:
New avatar is not set, and ENOENT error is displayed
Server Setup Information:
Client Setup Information
Additional context
It seems to be the case that something in our setup is the cause, becasue we could not reproduce it with clean db. Whlie trying to figure out, what could be the case, we checked rocketchat_avatars collection for any kind of strange documents. While testing it out, we noticed, that filename that is referenced in ENOENT error is actually not in our uploads directory (we are using FileSystem storage). But there was a document in rocketchat_avatars that had an _id, of that same file in ENOENT error. After deleting this document, it was possible to upload a new avatar, but if we tried to upload avatar again after that, the ENOENT error would still occur with filename that is referenced in new _id field of that newly created document. It is something in our setup it seems, but we can't really figure out what it is.
Relevant logs:
users.setAvatar response in DevTools:
the same log from server: