Meteor-files: [SOLVED] "base64 is not a function" since updated to 1.7.10

Created on 15 Feb 2017  路  22Comments  路  Source: veliovgroup/Meteor-Files

TL:DR; update node to version 4.7.3 or higher 鉃★笍 SOLVED

Hello all,
I got an issue when uploading in prod (this works in dev strangely). I catch the error from the call back from the insert on end with a nice Error during upload: Error: Internal server error [500] delivered to the client in the error param.

So I looked at the server log and here is what I get:

Exception while invoking method '_FilesCollectionWrite_images' TypeError: base64 is not a function
    at Function.from (native)
    at Function.from (native)
    at [object Object].FilesCollection._methods.(anonymous function) (/home/gui/bookmeonline/programs/server/packages/ostrio_files.js:1385:35)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1737:12)
    at packages/ddp-server/livedata_server.js:719:19
    at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
    at packages/ddp-server/livedata_server.js:717:40
    at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
    at packages/ddp-server/livedata_server.js:715:46
    at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:689:23)

It was working a couple days ago before my latest meteor update

Fixed In a case of the fire - Read This

Most helpful comment

Ok with node 4.7.3 it works for me ! Thx a lot guys

All 22 comments

Hello @guidouil

  1. Is it on production (after meteor build) or on development stage?
  2. If it's on production stage, what Meteor version you're on?
  3. Are you sure you're on v1.7.10?
  4. What Meteor version?

Yes it's in production after a meteor build.
(this all work in local)
I'm running Meteor 1.4.2.7
and yes in the .meteor/versions I see ostrio:[email protected]

Whoops, I meant to ask Node.js version.
On dev stage everything is ok?

Node version 4.4.2

I just updated to 4.7.3 (as meteor uses in local) and I have the same issue... do you recommend another version ?
The server is an Ubuntu 15.04 updated regularly packages wide but not up to the latest LTS.

And yes on dev stage (localhost:3000) everything work fine.

Hello,
I have exactly the same issue.

Hello @marcchapeau ,

Could you please clarify next:

  1. Is it on production (after meteor build) or on development stage?
  2. If it's on production stage, what Meteor version you're on?
  3. Are you sure you're on v1.7.10?
  4. What Node.js version?

@marcchapeau and @guidouil

If it's possible could you post full logs from server and client, after setting debug: true option on FilesCollection Constructor?

So far I have tested latest package version on Node.js (v4.7.3) on heroku, Digital Ocean Ubuntu, Digital Ocean Debian, and on my own server running Debian. And I can not reproduce this issue.

I'm also confused about __TypeError__: base64 is not a function - are you using TypeScript?

And now with the debug activated it works fine 馃槮
here is the log of an upload and delete doing great... go figure

[FilesCollection] [File Start Method] TQXxM3oeX2P6G8MhB.png - NozcRCoa6wPkAHcgy
[FilesCollection] [Upload] [DDP Start Method] Got #-1/1 chunks, dst: TQXxM3oeX2P6G8MhB.png
[FilesCollection] [Upload] [DDP] Got #1/1 chunks, dst: TQXxM3oeX2P6G8MhB.png
[FilesCollection] [Upload] [DDP] Got #-1/1 chunks, dst: TQXxM3oeX2P6G8MhB.png
[FilesCollection] [Upload] [finish(ing)Upload] -> /data/uploads//NozcRCoa6wPkAHcgy.png
[FilesCollection] [Upload] [finish(ed)Upload] -> /data/uploads//NozcRCoa6wPkAHcgy.png
[FilesCollection] [_preCollectionCursor.observe] [changed]: NozcRCoa6wPkAHcgy
[FilesCollection] [Unlink Method] [.remove([object Object])]
[FilesCollection] [find({"_id":"KpdjybwR9TNhwg5gs"}, undefined)]
[FilesCollection] [remove({"_id":"KpdjybwR9TNhwg5gs"})]
[FilesCollection] [unlink(KpdjybwR9TNhwg5gs, undefined)]
[FilesCollection] [_preCollectionCursor.observe] [removed]: NozcRCoa6wPkAHcgy

And no, not using TypeScript. Just Babel as recommended and many other packages and npm's of course :)

And now with the debug activated it works fine

Wow-wow... Have you tried to disable "debug-mode" and confirm it's not working again? I'm just curious is there possibility something went wrong during build or deploy?

Moreover _FilesCollectionWrite method has only this one debug line.

The thing is it's saying - "base64 is not a function" there is no place in package code with function or property called as function with name of base64, only four strings with value of base64.

  1. Yes it's in production after a meteor build. (work fine with dev mode)
  2. meteor version is 1.4.2.7
  3. i'm on MF 1.7.10
  4. node version is 4.4.7

Here is the server debug after trying to upload a file :

[FilesCollection] [File Start Method] la-video-la-plus-courte-du-pere-le-moins-responsable.mp4 - thNgQYcPWqjnEBcf2 [FilesCollection] [Upload] [DDP Start Method] Got #-1/4 chunks, dst: la-video-la-plus-courte-du-pere-le-moins-responsable.mp4 Exception while invoking method '_FilesCollectionWrite_uploads' TypeError: base64 is not a function at Function.from (native) at Function.from (native) at [object Object].FilesCollection._methods.(anonymous function) (/home/studios_42/prod/tv42/2017-02-15_22-00/bundle/programs/server/packages/ostrio_files.js:1385:35) at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12) at packages/ddp-server/livedata_server.js:711:19 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at packages/ddp-server/livedata_server.js:709:40 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at packages/ddp-server/livedata_server.js:707:46 at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:681:23) Exception while invoking method '_FilesCollectionWrite_uploads' TypeError: base64 is not a function at Function.from (native) at Function.from (native) at [object Object].FilesCollection._methods.(anonymous function) (/home/studios_42/prod/tv42/2017-02-15_22-00/bundle/programs/server/packages/ostrio_files.js:1385:35) at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12) at packages/ddp-server/livedata_server.js:711:19 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at packages/ddp-server/livedata_server.js:709:40 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at packages/ddp-server/livedata_server.js:707:46 at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:681:23) [FilesCollection] [remove({"_id":"thNgQYcPWqjnEBcf2"})] Exception in queued task: TypeError: Cannot read property 'path' of undefined at Object.removed (/home/studios_42/prod/tv42/2017-02-15_22-00/bundle/programs/server/packages/ostrio_files.js:977:120) at [object Object].observeChangesCallbacks.removed (packages/minimongo/observe.js:169:28) at self.applyChange.removed (packages/minimongo/observe.js:71:44) at packages/mongo/observe_multiplex.js:182:30 at Array.forEach (native) at Function._.each._.forEach (packages/underscore.js:139:11) at Object.task (packages/mongo/observe_multiplex.js:176:9) at [object Object]._.extend._run (packages/meteor.js:807:18) at packages/meteor.js:785:14 [FilesCollection] [unlink(thNgQYcPWqjnEBcf2, undefined)]

With debug mode ON, the problem still be there.

Thx

@marcchapeau @guidouil

So, as I understood - this error pops-up only on production, right?
If so - is this issue reproduces on dev stage wth --production flag?

And on my side without the debug it works again... So I guess it's thanks to the node update to 4.7.3 and I did not detect it before because I did not rebuild my meteor app but just stopped it and restarted. @marcchapeau can you try to update your node to 4.7.3 to see if it does fix the issue ? (I used nvm to choose exact version)

@dr-dimitru yes only in production after building with node 4.4.x it seems...

Exactly, this error pops-up only on production.
I just tried with meteor --production and it works fine.

I will try to update node to 4.7.3

I used nvm to choose exact version

I prever to compile node.js of required version on the server. NVM is good solution too褞

I use nvm too but the same error occured with node 4.7.3

@marcchapeau did you rebuild the server tarball after node update?

Oh excuse me ! I'am a liar :) I change the node version to 4.7.3 but start my server with the absolute path of node 4.4.7. Sorry, just give me a second.

Ok with node 4.7.3 it works for me ! Thx a lot guys

Meanwhile I found the roots of the issue.
Since node v5.* new Buffer() constructor is deprecated and Buffer.from method must be used instead. So we've added pollyfill to check if Buffer.from is supported, so folks can run meteor on newer node.js.

Weird thing is somewhere between node v4.5.* and v4.7.* Buffer.from is implemented partially, without base64 support.

@guidouil @marcchapeau

I'm glad you have fixed this issue. That was a good reason to update node.js to newer and recommended version for Meteor.

Please, support this project by:

Fix with better polyfill released as v1.7.11

Guys @guidouil @marcchapeau thank you for contribution

Was this page helpful?
0 / 5 - 0 ratings