vsivsi / meteor-file-collection

Extends Meteor Collections to handle file data using MongoDB gridFS.
http://atmospherejs.com/vsivsi/file-collection
Other
159 stars 37 forks source link

DeprecationWarning in Meteor 1.6 / Node 8 #170

Closed edemaine closed 6 years ago

edemaine commented 6 years ago

Meteor 1.6 upgrades to Node 8 which adds this deprecation of root as an alias for global. vsivsi:file-collection does not seem to use the root alias. Nonetheless, I'm getting a DeprecationWarning on the last line of this compiled JavaScript:

    function FileCollection(root, options) {
      var indexOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, self;
      this.root = root != null ? root : share.defaultRoot;

which comes from this line of CoffeeScript. (If you want to test, set environment variable NODE_OPTIONS to --throw-deprecation so that you can see what line is causing the warning.)

I don't understand why this DeprecationWarning is triggering. The relevant nodejs code seems to just make a global variable called root that behaves in this way, but root is clearly an argument to FileCollection. OK, here are some experiments in Node 8 (meteor node):

> function f(root) { console.log(root) }
undefined
> f(5)
5
undefined
> function g(root) { this.root = root; }
undefined
> g(5)
DeprecationWarning: 'root' is deprecated, use 'global'
    at g (repl:1:30)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
[restart Node to reset warning]
> function h() { this.root = 5; }
undefined
> h()
DeprecationWarning: 'root' is deprecated, use 'global'
    at h (repl:1:26)
    at repl:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:120:20)
    at REPLServer.emit (events.js:210:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
>

So this means that this is getting set to the global environment... Oops, this is because I'm calling FileCollection instead of doing new FileCollection. My bad.

vsivsi commented 6 years ago

Glad you were able to figure it out!