Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Upload is not working

Open kaji-bikash opened this issue 10 years ago • 33 comments

We are on latest snap package and 🚀 chat is at Version: 0.40.1

Here's the background: It was working previously in 0.38 version. It stopped working after the upgrade of a snap package. Actually, I was fiddling with settings on AVATAR upload path and I remember setting to FILESYSTEM with /opt/avatar and I broke it. Since server itself was not starting up, I had to change things from backend through MongoDB console in rocketchat.settings collection ( reverted to GridFS).

We started experiencing this as well. Symptoms are almost the same but the scenarios are different.

When "upload" settings are tied to "Filesystem", the progress bar would freeze at 100% and nothing happens at all no matter the time. We get following in the log

ufs: cannot write file "zkb9tX9CKP8zLkX2W" (EROFS: read-only file system, open '/zkb9tX9CKP8zLkX2W.gif') { [Error: EROFS: read-only file system, open '/zkb9tX9CKP8zLkX2W.gif']
  errno: -30,
  code: 'EROFS',
  syscall: 'open',
  path: '/zkb9tX9CKP8zLkX2W.gif' }
Exception while invoking method 'ufsComplete' Error: EROFS: read-only file system, open '/zkb9tX9CKP8zLkX2W.gif'
    at Object.Future.wait (/snap/rocketchat-server/45/node_modules/fibers/future.js:449:15)
    at [object Object].ufsComplete (meteor://💻app/packages/jalik:ufs/ufs-methods.js:62:20)
    at [object Object].methodsMap.(anonymous function) (meteor://💻app/packages/rocketchat:lib/server/lib/debug.js:17:26)
    at maybeAuditArgumentChecks (meteor://💻app/packages/ddp-server/livedata_server.js:1711:12)
    at meteor://💻app/packages/ddp-server/livedata_server.js:711:19
    at [object Object]._.extend.withValue (meteor://💻app/packages/meteor/dynamics_nodejs.js:56:1)
    at meteor://💻app/packages/ddp-server/livedata_server.js:709:40
    at [object Object]._.extend.withValue (meteor://💻app/packages/meteor/dynamics_nodejs.js:56:1)
    at meteor://💻app/packages/ddp-server/livedata_server.js:707:46
    at Session.method (meteor://💻app/packages/ddp-server/livedata_server.js:681:23)
    at meteor://💻app/packages/ddp-server/livedata_server.js:551:43
    - - - - -
    at Error (native)
ufs: cannot delete temp file "/tmp/ufs/zkb9tX9CKP8zLkX2W" (ENOENT: no such file or directory, unlink '/tmp/ufs/zkb9tX9CKP8zLkX2W')

As for GridFS case, upload shows it worked fine but we get the blank placeholder of zero-byte / an empty file. However, nothing gets vomited in logs in this case. screen shot 2016-09-23 at 11 17 29

kaji-bikash avatar Sep 23 '16 16:09 kaji-bikash

@geekgonecrazy Was this resolved in the #ubuntu-snap channel or is this still ongoing?

graywolf336 avatar Sep 24 '16 03:09 graywolf336

Ongoing. Couple other reports in non snap installs. Trying to get to the bottom of it still

geekgonecrazy avatar Sep 24 '16 05:09 geekgonecrazy

I am experimenting the same problem using the latest #ubuntu-snap

rodripf avatar Sep 26 '16 17:09 rodripf

@rodripf experimenting or experiencing ? For former, thank you :) and for the latter, kudos for validating my case 👍

kaji-bikash avatar Sep 26 '16 18:09 kaji-bikash

I am on snap 0.41 and I am experiencing this too.

tlaerm avatar Oct 06 '16 18:10 tlaerm

I’m experiencing this issue too. Here are some details about the behaviour on my side:

I’m also running the latest snap. Avatar images and file uploads are both set to GridFS. In both cases, I get an empty file after upload (just like OP) and no warning or error message.

However, both file upload and avatar images work if I start the server directly in Node JS (without running it through Snap), e.g. like this:

cd /snap/rocketchat-server/current/
export ROOT_URL=http://localhost PORT=3000 MONGO_URL=mongodb://localhost:27017/parties
./bin/node main.js

So the issue seems very snap specific.

I noted that for me, uploading files only doesn’t work for image files (e.g. pdf is okay). Furthermore, Avatar images work if I disable resizing them.

Does Rocket.Chat try to resize uploaded images? (Or run them through graphicsmagick for any other reason?) If yes, can this be disabled? Because that could be a workaround.

If the issue is really because of graphicsmagick, my wild guess would be that Rocket.Chat cannot find the gm executable in its Snap container.

To summarize, the situation on my server is like this:

Running through snap Running directly through Node JS
Avatar upload with resizing No Yes
Avatar upload without resizing Yes Yes
Image upload No Yes
Other File upload Yes Yes

jGleitz avatar Oct 08 '16 12:10 jGleitz

@jGleitz It looks like it uses $SNAP/usr/bin/convert.

vim stable/snapcraft.yaml

stage-packages:
  - imagemagick
organize:
   usr/bin/convert-im6: usr/bin/convert

falkowich avatar Oct 08 '16 17:10 falkowich

It looks like it uses $SNAP/usr/bin/convert.

Good hint. But if it’s using its own binary, then why is there a difference between running inside the snap and “outside”?

I thought Rocket.Chat would use gm because that’s mentioned in this bug:

Rocket.Chat uses GraphicsMagick for resizing, so you'd have to have that installed on your box.

Is that outdated info?

jGleitz avatar Oct 08 '16 20:10 jGleitz

Both imagemagick and graphicsmagick provide the convert command. Rocket.Chat works with either one of them. We install imagemagick and include it in the snap.

Snaps are a isolated environment. Its packaged up with all of its dependencies. Also its restricted on which files and folders it can access. It can just access any file or folder it wishes. They are tightly controlled by the snap platform. This is one of the big benefits to using snaps.

So it appears for some reason its trying to use a file or folder it doesn't have access to on file upload.

geekgonecrazy avatar Oct 09 '16 20:10 geekgonecrazy

I can confirm @jGleitz's findings. Exact same symptoms for me.

tlaerm avatar Oct 10 '16 21:10 tlaerm

In the latest snap it should be fixed.

We used to work with imagemagick or graphicsmagick. Something changed and if using imagemagick it seems to screw things up. So Graphicsmagick is required.

geekgonecrazy avatar Oct 11 '16 16:10 geekgonecrazy

And so it is. Thanks for your efforts.

tlaerm avatar Oct 21 '16 18:10 tlaerm

I encountered that exact same issue. Rocket.Chat Version: 0.54.2 Ubuntu 16.04 / snap install

Can't it be due to file system access restriction inherent to snaps?

maxlath avatar Apr 12 '17 14:04 maxlath

@maxlath if you have it setup to point to a filesystem path. Then yes absolutely. What path do you have specified?

geekgonecrazy avatar Apr 12 '17 23:04 geekgonecrazy

@geekgonecrazy I let the path field unaltered

maxlath avatar Apr 12 '17 23:04 maxlath

@maxlath could you grab the value and paste it here? Its possible this value got messed up and maybe something we need to address.

geekgonecrazy avatar Apr 12 '17 23:04 geekgonecrazy

Step to reproduce:

  • Installed a fresh Rocket.Chat Version: 0.54.2 snap
  • After signing up, changed File Upload > Storage Type to FileSystem, without change anything else.
  • Back in the general room, trying to upload a small image displays the Upload File? modal correctly but once hitting Send, a message notify you of an internal server error:
ufs: cannot delete temp file at /tmp/ufs/WmDJcA9nSB24rn697 (ENOENT: no such file or directory, unlink '/tmp/ufs/WmDJcA9nSB24rn697')
ufs: cannot write file "WmDJcA9nSB24rn697" (EROFS: read-only file system, open '/WmDJcA9nSB24rn697.jpg') { [Error: EROFS: read-only file system, open '/WmDJcA9nSB24rn697.jpg']
  errno: -30,
  code: 'EROFS',
  syscall: 'open',
  path: '/WmDJcA9nSB24rn697.jpg' }
Exception while invoking method 'ufsComplete' Error: EROFS: read-only file system, open '/WmDJcA9nSB24rn697.jpg'
  at Object.Future.wait (/snap/rocketchat-server/580/node_modules/fibers/future.js:449:15)
  at [object Object].Meteor.methods.ufsComplete (/snap/rocketchat-server/580/programs/server/packages/jalik_ufs.js:824:24)
  at [object Object].methodsMap.(anonymous function) (/snap/rocketchat-server/580/programs/server/packages/rocketchat_lib.js:1095:26)
  at maybeAuditArgumentChecks (/snap/rocketchat-server/580/programs/server/packages/ddp-server.js:1817:12)
  at /snap/rocketchat-server/580/programs/server/packages/ddp-server.js:905:20
  at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
  at /snap/rocketchat-server/580/programs/server/packages/ddp-server.js:904:41
  at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
  at /snap/rocketchat-server/580/programs/server/packages/ddp-server.js:903:46
  at [object Object]._.extend.protocol_handlers.method (/snap/rocketchat-server/580/programs/server/packages/ddp-server.js:876:21)
  at /snap/rocketchat-server/580/programs/server/packages/ddp-server.js:755:85
    - - - - -
  at Error (native)
ufs: cannot delete temp file "/tmp/ufs/WmDJcA9nSB24rn697" (ENOENT: no such file or directory, unlink '/tmp/ufs/WmDJcA9nSB24rn697')

maxlath avatar Apr 13 '17 09:04 maxlath

@maxlath what is the value of the filesystem path? Snaps are only allowed to write to certain places. So this is an important​ piece to verify

geekgonecrazy avatar Apr 13 '17 13:04 geekgonecrazy

@geekgonecrazy the input[name='FileUpload_FileSystemPath'] value is empty, is there another place I should check or is that the value you are looking for?

maxlath avatar Apr 13 '17 14:04 maxlath

That's the value. It should be something like: /var/snap/rocketchat-server/common/uploads

geekgonecrazy avatar Apr 13 '17 16:04 geekgonecrazy