Original Message:
Sent: Wed October 02, 2024 03:15 AM
From: Mustafa Almonayer
Subject: API Connect GatewayScript remote debugger
Hey Steve, I figured a way to enable the remote debugger no matter the name of the API, you just have to set a value to true in the context before the script.
Here is a portion of my yaml file.
assembly:
execute:
- set-variable:
version: 2.0.0
title: set-variable
actions:
- set: policy.gatewayscript.enableDebugger
value: true
type: boolean
- gatewayscript:
version: 2.0.0
title: gatewayscript
source: |
debugger;
var data = "data";
debugger;
------------------------------
Mustafa Almonayer
Original Message:
Sent: Tue October 01, 2024 01:34 PM
From: Steve Linn
Subject: API Connect GatewayScript remote debugger
Hi Mustafa,
It is possible, although it requires you to have access to the DataPower appliance where the Gateway resides. There are two requirements of the GatewayScript debugger, remote or the CLI version.
1. The .js code to be debugged must have a debugger; statement that will designate the first breakpoint where the code execution will pause.
2. The DataPower action that executes the .js must have GatewayScript debugging enabled. For the API Gateway, that is the tricky part. The name of the GatewayScript action is made unique on the publish of your catalog to ensure that your API named "test" and my API named "test" don't collide. This also is done for all child actions within the API Definition object. For example, I have Assembly GatewayScript actions of the name swlinnorg_sandbox_test_1.0.0_gatewayscript_0 where my organization name is swlinnorg, my catalog sandbox, my API name of test, my API version 1.0.0, the action type, in this case gatewayscript, and finally, a numeric value indicating the nth action of that type in the API which is zero based. On DataPower you will need to bring up that action where you can click on the link to enable the GatewayScript debugger. Also note that if you should republish this catalog with this API, that the Assembly GatewayScript action would be reset, requiring you to go thru this process again to enable the debugger.
The debugger is a valuable tool to use during API development. It goes without saying it should never be used in production :-). I'm assuming you don't have access to the DataPower CLI which is why you're looking to use the remote debugger, but once the GatewayScript execution is paused, you can use chrome://inspect which when configured to look at your DataPower appliance at the correct port for the remote debugger that you should be able to use the debugger to see your code, inspect and change variables, and follow the execution path. I believe only 10 active debug sessions are allowed at any one time, so if you should have more, those will ignore the initial breakpoint and will execute to completion.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Sun September 29, 2024 03:45 AM
From: Mustafa Almonayer
Subject: API Connect GatewayScript remote debugger
I want to ask if it's possible to use the remote debugger for debugging JavaScript code using the GatewayScript policy in the flow assembly, I'm using API Connect version 10.0.5.4 and DataPower API Gateway version 10.5.0.6, I have configured the remote debugger and inserted the debugger; statement in the code but the debugger doesn't seem to work, I want to know if it's supported and if it's a misconfiguration or if it the remote debugger is not supported using the GatewayScript policy in API Connect ?
Much Thanks.
------------------------------
Mustafa Almonayer
------------------------------