Debugging

EdgeWorkers supports request-level debugging via the Pragma request header. If a request passes a Pragma request header containing EdgeWorkers specific values, the related trace response headers are returned. These trace response headers contain information about the EdgeWorker executed during the request or response.

Note: The trace response header format may change in the future to include new fields.

The Pragma value can be one or more of the following:

Akamai Pragma Header Returns debug information from
akamai-x-ew-debug all event handlers
akamai-x-ew-onclientrequest only the onClientRequest event handler
akamai-x-ew-onoriginrequest only the onOriginRequest event handler
akamai-x-ew-onoriginresponse only the onOriginResponse event handler
akamai-x-ew-onclientresponse only the onClientResponse event handler
Here's a curl request that passes the Pragma akamai-x-ew-debug response header:
curl "http://www.mofroyo.co" -H "Pragma: akamai-x-ew-debug" -sD -
This example shows the trace response headers with successful execution of all event handlers:
HTTP/1.1 302 Moved Temporarily
Location: /us/en/
Content-Type: text/html
Content-Length: 0
Date: Tue, 10 Sep 2019 02:31:17 GMT
Connection: keep-alive
X-Akamai-EdgeWorker-onClientResponse-Info: ew=9 v7.0:EW for example.com; status=Success; status_msg=
X-Akamai-EdgeWorker-onClientRequest-Info: ew=9 v7.0: EW for example.com; status=Success; status_msg=
X-Akamai-EdgeWorker-onOriginResponse-Info: ew=9 v7.0:EW for example.com; status=Success; status_msg=
X-Akamai-EdgeWorker-onOriginRequest-Info: ew=9 v7.0: EW for example.com; status=Success; status_msg=
X-Powered-By: Akamai EdgeWorkers
Here's a curl request that passes the Pragma akamai-x-ew-onclientrequest response header:
curl "http://www.example.com" -H "Pragma: akamai-x-ew-onclientrequest" -sD -
This example shows the trace response header with an execution error:
HTTP/1.1 500 Internal Server Error
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 174
Expires: Thu, 12 Sep 2019 15:11:24 GMT
Date: Thu, 12 Sep 2019 15:11:24 GMT
Connection: close
X-Akamai-EdgeWorker-onClientRequest-Info: ew=9 v7.0:EW for example.com; status=ExecutionError; status_msg=main.js:runtime_error:5:2,main.js:red_team:16:3,main.js:onClientRequest:39:3+ReferenceError:+calling_undefined_fn+is+not+defined
AK_EIP_FORWARDER_IP:

The EdgeWorker trace response header value currently contains EdgeWorker details, the error type, and an error message. The trace header format will be updated as new fields are added to the response.

Response Header fields Details Description
EdgeWorker details

ew=<id> v<version>:<name>
<id> EdgeWorker ID
<version> EdgeWorker version number
<name> EdgeWorker name
Status type

status=<status type>
<status type> Possible values include:
  • Success - the EdgeWorker successfully executed.
  • GenericError - a compile error, such as a syntax error occurred.
  • ExecutionError - an execution error, such as a JavaScript exception or error occurred.
  • RuntimeError - an error occurred at runtime/environment preventing the EdgeWorker from executing.
  • UnknownEdgeWorker - the EdgeWorker ID cannot be loaded because it doesn't exist.
  • UnimplementedHandler - the requested event handler wasn't implemented by the EdgeWorker.
  • TimeoutError - the execution time surpassed an upper limit restriction.
  • ResourceLimit - the upper bound of a resource limit was reached.
Status Message

status_msg=(<filename>:<function-name>:<line-number>:<column>)+ <error-description>
<function-name> Optional URL encoded function name where the error occurred.
<line-number> Optional line number where the error occurred.
<column> Column number where the error occurred.
<error-description> Error message for the exception.