Is there any way to step-debug Edge Micro plugin code? All attempts have been unsuccessful so far. Is this because plugins run in a vm sandbox? Any way around this? Should I be debugging the Agent, Gateway or both?
We've tired Node debugger and iron-node.
We will have it in next release. Currently agent does not has option to take debug params.
This response was two years ago.
Surely we must have have at least one "next release" of MG since then ...
... Is there still no way to step debug a custom plugin ?
The only way to debug is custom plugin is for the custom plugin to use the "debug" npm module. You can then use the DEBUG environment variable to selectively enable debug for specific packages. Take a look at the plugins Apigee has developed, it uses the same method.
Implementing your suggestion, I am able to filter the debug output lines, restricting them to a single proxy I am interested in. I am still not getting to step-debug the plugin.
Out of interest for other readers, here's the (Windows) environment setup required.
[npm prefix] \node_modules\edgemicro\plugins\your-plugin>npm install debug
var debug = require('debug')('plugin:your-plugin'); and under the function debug('your plugin message here');
Now when you run your plugin, only debug print lines from your plugin will be shown.
If you issue inspect, you can see the gateway console react, issuing message …
Debugger listening on port 5859.
You can also connect to the debug session under Chrome via “about://inspect”.
To break on the first statement of the script, use --inspect-brk
(In Node 6, you have to use --inspect --debug-brk )
The system will pause on the first line … from where you can debug as expected.
This is encouraging progress !! :smiley
But that’s where we get stuck, despite stepping through the code line by line.
Ideally we want to have the debug session stop when the plugin is loaded/called etc.
We seem to lose debugging when files other than app.js includes are loaded.
I was able to do step debugging of my plugin by invoking the edgemicro executable (script) from node with the --inspect-brk flag.
Instead of
edgemicro start -p 1
I used
node --inspect-brk /Users/PAT5422/.nvm/versions/node/v8.5.0/lib/node_modules/edgemicro/cli/edgemicro start -p 1
I'm sure this is a resource hog as you are debugging all of edgemicro this way, but in Chrome Dev Tools you are able to find your plugin js file easily enough and add breakpoints.
User | Count |
---|---|
6 | |
2 | |
1 | |
1 | |
1 |