Enable harmony proxies at runtime in node.js

醉酒当歌 提交于 2020-01-05 03:08:12

问题


I have a little RPC library for node, and right now it uses harmony proxies for remote objects if they are available (by checking for the existence of a Proxy global).

I'd like to be able to turn harmony proxies on at runtime, that is, in a node process that was not started with the --harmony-proxy flag. Is this possible?

I understand that there are good reasons not to do this, and I don't really care :-P

EDIT As pointed out in the answers, node.js proxies use an older spec. I can use a shim like https://github.com/tvcutsem/harmony-reflect to work around this, but this still requires the --harmony flag to enable the underlying proxy support, and I want to know whether it's possible to enable that at runtime in a process started without the --harmony flags.


回答1:


The version of Proxy is depend on whether you use master or v0.10. Latest stable (v0.10) uses the 3.14 branch, while development (master) stays with v8 bleeding_edge (currently at 3.20). So the more correct question is, "what version of proxies has v8 implemented?"

Work is being done on the proxy implementation, but it's a moving target right now. Referencing the proxy implementation ticket in the bug tracker (http://code.google.com/p/v8/issues/detail?id=1543) it looks like another round of changes are coming. So be careful with upcoming development.

As far as enabling proxies in the app and not the command line I believe you'll have to write a native module and use the V8::SetFlagsFromString method (https://github.com/v8/v8/blob/f281162/include/v8.h#L4341-L4344). If you need an example I might make time to whip one up.




回答2:


Node.js implements an older proxy specification. Don't use them.

https://groups.google.com/forum/?fromgroups=#!topic/nodejs/LPD8ut33-hg



来源:https://stackoverflow.com/questions/17394791/enable-harmony-proxies-at-runtime-in-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!