Is it possible to debug code that's been generated by eval()?

 I love the webstorm! Using 2016.1 for Node.js.

I have code snippets extracted from a database that gets eval'd and then executed. I know, I know, everywhere I turn other developers slap my hand and tell me me how awful it is use eval. Commentary on that evil practice aside, is there any way to debug code that's been eval'd? Would be very helpful! Thanks.

5 comments
Comment actions Permalink

there is currently no way to debug generated code that has no file associated with it and it lives in V8 VM only. Please follow https://youtrack.jetbrains.com/issue/WEB-7420 for updates

 

I can suggest trying Node Inspector for this - seems it can debug generated code (see https://github.com/node-inspector/node-inspector/issues/171)

0
Comment actions Permalink

Thank you for the suggestion Elena. Turns out that the code is extracted from MongoDb, and is therefore not present in a file to allow the technique of using <code>node --debug-brk --file_name</code>. 

Does Jetbrains have any plans to add the feature to be able to debug dynamically generated code without having the code resident in an file?

Thanks again for getting back to me!

Greg

 

0
Comment actions Permalink

yes - please vote for ticket mentioned above (https://youtrack.jetbrains.com/issue/WEB-7420 ). Not sure when this feature can be expected though...

0
Comment actions Permalink

Thanks again. Just gave it the big thumbs up.

I'm cheering for you Vladimir Krivosheev!

:-)

0
Comment actions Permalink

I love the new capability! Code is uploaded from a mongodb instance and therefore is executed with javascript 'eval'. Works Great!!! Thanks Vladimir!

0

Please sign in to leave a comment.