You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vm.runInNewContext() & console.log causes devtools to disconnect #7814
I am building an app which runs user scripts in a sandboxed environment, so I want to use the Node vm module. Here is the code I use to load the user scripts:
functionrunInSandbox(visPath: string): IVisualization{letcontext={require: (moduleName)=>{// I implement a custom "safe" require method here},console: console,module: {}};letdata=fs.readFileSync(path.join(visPath,'index.js'));letresult=vm.runInNewContext(data,context,{ visPath });returnresult;}
// userscript/index.jsconsole.log('test');
Now, when I run the app without devtools open, the user scripts execute as expected. However, when I am running with the devtools open, as soon as one of the user scripts does a console.log, the devtools crashes with:
DevTools was disconnected from the page.
Once the page is reloaded, DevTools will automatically reconnect.
However, if I define the console object in the context thus:
console: {log: (...args)=>console.log(...args),},
then the script works fine and DevTools does not disconnect, which seems strange, since I have seen many examples online where the console object is defined as in the first example.
Activity
kevinsawicki commentedon Jan 6, 2017
The stack trace for this one is:
kevinsawicki commentedon Jan 6, 2017
This looks to be fixed in Chrome 54, I can't reproduce this on the #7909 branch.