Remote Debugging
Smile 2022.05 introduced support for JavaScript remote debugging via a Chrome browser.
Remote JavaScript debugging is enabled for a module in the "JavaScript Execution Environment" section of the module configuration. After enabling debug on the module, when you restart the module, if the module has any javascript callbacks configured, you will see a message in the logs that looks something like this:
Smile CDR JavaScript debugging enabled. Please copy-paste the following URL into a Chrome browser to continue startup: devtools://devtools/bundled/js_app.html?ws=localhost:9930/018b9c18-5efa-4163-b40d-a4b0b56bb4b3
The module will pause until you click the "Resume script execution" button, the blue arrow on the top-left of this image:
From here, you can set breakpoints, examine variables, step into functions, and any other typical debugging activity.
You can use Debug Host Address
, Port
and Secure
to control the url the JavaScript Execution Environment will listen on for connections.
If Suspend
is set to "No", then the log message with the URL will still be written to the log, but the module will not pause and wait for the debug client to connect. The debug client can connect any time after the log message appears.
If no Path
is set, then the server will create a new random UUID every time the server restarts. You can override this and set the path what you want it to be. E.g. if you set the path to mysecretpath
then the URL you need to connect to will look like:
Smile CDR JavaScript debugging enabled. Please copy-paste the following URL into a Chrome browser to continue startup: devtools://devtools/bundled/js_app.html?ws=localhost:9930/mysecretpath
Setting the path can be useful if you are frequently restarting your module so your chrome debugger can reconnect to the same url after every restart. However, keep in mind that anyone with access to that port will be able to connect to this debug URL and potentially gain access to data visible to the JavaScript callback function, so we recommend if you set the Path
that you choose a name that is difficult to guess.