briankircho/mongoose-schema-extend

problem with harmony-reflect

Opened this issue · 4 comments

Hi
I have mongoose-schema-extend installed with a dependency to harmony-reflect@1.4.2
mongoose-schema-extend@0.2.1
└── harmony-reflect@1.4.2

this gives the following error

/home/ubuntu/git/nsoc-mwc/node_modules/mongoose-schema-extend/node_modules/harmony-reflect/reflect.js:2049
throw new Error("proxies not supported on this platform. On v8/node/iojs, make sure to pass the --harmony_proxies flag");
^

Error: proxies not supported on this platform. On v8/node/iojs, make sure to pass the --harmony_proxies flag
at new global.Proxy (/home/ubuntu/git/nsoc-mwc/node_modules/mongoose-schema-extend/node_modules/harmony-reflect/reflect.js:2049:13)
at Schema.extend.options as extend
at Object. (/home/ubuntu/git/nsoc-mwc/models/country.js:8:35)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object. (/home/ubuntu/git/nsoc-mwc/routes/ar_country.js:3:15)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)

reverting to a previous mongoose-schema-extend and harmony-reflect version fixes the problem
"mongoose-schema-extend": "0.2.0",
"harmony-reflect": "1.4.1",

Same issue here.

Meanwhile we switched our package.json from

 "dependencies": {
  ...
   "mongoose-schema-extend": "^0.2.0",
  ...

to


 "dependencies": {
  ...
   "mongoose-schema-extend": "0.2.0",
  ...

It is my fault, I'm sorry. The new release uses harmony proxies to solve some issues (v8 has not still included standard ES6 proxies, they will very soon) you can add the flag --harmony-proxies to your init script, or use the previous version. I will take a look to this very soon

So, short version

There was a major issue causing the middleware not to execute, making this library useless for many of its potential use cases.

I fixed it with this commit, which caused the error you are experiencing when I merged this branch. There was another option which was not functional (the reason why is included on the comments of the discarded PR).

The proper solution uses proxies. Unfortunately, v8 has not still fully implemented them. There is work in progress, and they will very soon include them. Meanwhile, the ES6 proxy interface is available using harmony-reflect, a façade to ES6 using ES5

I certainly released the new version too soon, as @efueyo said, you can go on using the previous release (0.2.0), or add the --harmony_proxies flag to your start command as it is done here, my personal advice is to do the latest, since this will allow you to use pre middleware.

As soon as v8 includes proxies, this will not be a problem anymore. I'll anyway update the docs and eventually allow to run the library without proxies (old behaviour), which will mean that not using the flag will result on the middleware not working.

Please consider reversing this. It appears to be impossible to pass "--harmony_proxies" to node via PM2. In addition, V8 is very much a javascript staple - if the library uses features unsupported by V8, it becomes useless to an awful lot of people.