You can debug a script in the Salesforce
B2C Commerce plugin script debugger or set breakpoints in the Eclipse
JavaScript editor. This topic describes how to debug in the B2C Commerce plugin
script debugger.
Script debugging impacts script execution
performance. When you launch a script debugging session, the server must
evaluate the script's current position to determine if a breakpoint is
reached. Salesforce doesn't recommend script debugging on Production
servers unless absolutely necessary.
When debugging a pipeline or script that is executed in the context of
the job and for a particular site, the cartridge must be in both the
Business Manager site so that the Job can find the pipeline, and the
cartridge must be in the cartridge path of the site for the debugger to
resolve. If you do not include the cartridge in the site's path, the
debugger will not resolve the breakpoint.
- Switch to the Debug perspective. You can do
this from the main menu by selecting Window > Open
Perspective > Other > Debug. The Debug perspective
appears.
- Click the arrow next to the bug icon
beneath the Run menu option.
- From the menu, select a script debugging configuration. If you have
not created any script debugging configurations, see Configuring a Script
Debugging Session.
Note: A pipeline debugging
configuration will not work with the script debugger.
-
Add a
breakpoint to your code by clicking in the margin to the left of your
code. For more information about creating breakpoints, see Setting Breakpoints.
- Open your storefront in a browser and perform the action that
triggers the script. The Debugger launches and stops at the first
breakpoint. At this point the breakpoint toolbar is enabled and you can
step through the
script.
Troubleshooting the Debugger
Log files are available in your UX Studio
installation at Studio\workspace\.metadata\.log
Launching The Debugger for the First Time
If you can't get the debugger to launch, make sure
that:
- your cartridge is in the active cartridge
path
- you have not added your cartridge after
creating the current code deployment version. If you have added your
cartridge after creating the version, create a new version in Business
Manager and switch between the new version and the existing version,
to trigger the server to update the cartridges in the active cartridge
path.
- you launched a script debugger
configuration instead of a pipeline debugger configuration
Relaunching the Debugger
If
you are using the script debugger successfully and have difficulty getting
it to relaunch after terminating a session, take the following
troubleshooting steps:
- Check to make sure your session is still connected
- Restart Studio
- Ask Customer Support to restart your instance. This returns the
script debugger to a good state.
You might also find the following debugging tools useful:
pipeline profiler,
pipeline debugger, and the storefront
toolkit request log.