Asset Compute workers can be debugged in several ways, from simple debug log statements, to attached VS Code as a remote debugger, to pulling logs for activations in Adobe I/O Runtime initiated from AEM as a Cloud Service.
The most basic form of debugging Asset Compute workers uses traditional console.log(..)
statements in the worker code. The console
JavaScript object is an implicit, global object so there is no need to import or require it, as it is always present in all contexts.
These log statements are available for review differently based on how the Asset Compute worker is executed:
aio app run
, logs print to standard out and the Development Tool’s Activation Logsaio app test
, logs print to /build/test-results/test-worker/test.log
wskdebug
, logs statements print to the VS Code Debug Console (View > Debug Console), standard outaio app logs
, log statements print to the activation log outputUse Microsoft Visual Studio Code 1.48.0 or greater for compatibility with wskdebug
The wskdebug npm module, supports attaching a debugger to Asset Compute workers, including the ability to set breakpoints in VS Code and step through the code.
Click-through of debugging an Asset Compute worker using wskdebug (No audio)
Ensure Docker Desktop and the supporting Docker images are installed and running
Close any active running instances of Development Tool.
Deploy the latest code using aio app deploy
and record the deployed action name (name between the [...]
). This is used to update the launch.json
in step 8.
ℹ Info: Deploying package [wkndAemAssetCompute-0.0.1]...
Start a new instance of Asset Compute Development Tool using the command npx adobe-asset-compute devtool
In VS Code, tap the Debug icon in the left navigation
launch.json
file.launch.json
in the editor.Add the following JSON object configuration to the configurations
array:
{
"type": "pwa-node",
"request": "launch",
"name": "wskdebug",
"attachSimplePort": 0,
"runtimeExecutable": "wskdebug",
"args": [
"wkndAemAssetCompute-0.0.1/__secured_worker", // Version must match your Asset Compute worker's version
"${workspaceFolder}/actions/worker/index.js", // Points to your worker
"-l",
"--ngrok"
],
"localRoot": "${workspaceFolder}",
"remoteRoot": "/code",
"outputCapture": "std",
"timeout": 30000
}
Select the new wskdebug from the dropdown
Tap the green Run button to the left of wskdebug dropdown
Open /actions/worker/index.js
and tap to the left of the line numbers to add break points 1. Navigate to the Asset Compute Development Tool Web browser window opened in step 6
Tap the Run button to execute the worker
Navigate back to VS Code, to /actions/worker/index.js
and step through the code
To exit the debug-able Development Tool, tap Ctrl-C
in the terminal that ran npx adobe-asset-compute devtool
command in step 6
AEM as a Cloud Service leverages Asset Compute workers via Processing Profiles by directly invoking them in Adobe I/O Runtime. Because these invocations do not involve local development, their executions cannot be debugged using local tooling such as Asset Compute Development Tool or wskdebug. Instead, the Adobe I/O CLI can be be used to fetch logs from the worker executed in a particular workspace in Adobe I/O Runtime.
Ensure the workspace-specific environment variables are set via AIO_runtime_namespace
and AIO_runtime_auth
, based on the workspace requiring debugging.
From the command line, execute aio app logs
--limit
flag:$ aio app logs --limit=25
The most recent (up to the provided --limit
) activations logs are returned as the output of the command for review.