简体   繁体   中英

Javascript Proxy (Node) in Visual Studio 2017 Causes Blocking When Debugging

I am developing a Node application/game in Visual Studio 2017 with Node v6.10.1. I am attempting to use ECMA 2015 Proxy objects. The Proxy objects work as expected as long as there are no breakpoints set around proxy creations or during certain proxied calls (eg get()). I am wondering if, (1) anyone else has experienced/solved this problem, (2) if this happens with later versions of Node/VS 2017.

Sample code:

    var realObject = { answer: 42, question: undefined };
//  Setting breakpoint on following line will cause blocking on Node thread.
    var proxy = (function (_this) {
        var _proxy =  new Proxy(_this, {
            get: function(target, property, receiver) {
               // Breakpoint on line below also causes blocking on Node thread
               return _this[property];
            },
            has: function (target, prop) {
                return prop in _this;
            }
        });
        return _proxy;
    })(realObject);

There are no errors and if you take the breakpoints out the code works as expected. It's not a show-stopper but it's annoying and makes troubleshooting much more difficult. I could upgrade Node if that helps but I am trying to develop against an older version to ensure compatibility.

Any help is greatly appreciated!

I finally gave in and upgraded to Node 8.9.3 and that appears to have solved the problem. I can set breakpoints and resume without any blocking issues :P

I noticed that Visual Studio launches with a couple of switches I didn't notice before that might have something to do with it:

node --inspect --debug-brk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM