Skip to content

Commit

Permalink
feat(RuntimeUpgrade): Added additional troubleshooting scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
bpeckNR committed Sep 19, 2024
1 parent f58b7af commit 8c0d5a8
Showing 1 changed file with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,36 @@ The [Node.js 16 and newer scripted API runtimes](/docs/synthetics/synthetic-moni

## Scripted API: Unexpected token JSON.parse errors

Attempting to use the `JSON.parse` function while interacting with the response body may produce unexpected token errors in scripted API monitors using the Node.js 16 and newer runtime. If the content-type response header is `application/json`, the response body being returned by the `$http` object will be parsed JSON. Additional calls attempting to use `JSON.parse` to parse the response body will fail with this error because the response body has already been parsed.
Attempting to use the `JSON.parse` function while interacting with the response body may produce unexpected token errors in scripted API monitors using the Node.js 16 and newer runtime. If the content-type response header is `application/json`, the response body being returned by the `$http` object will be parsed JSON. Additional calls attempting to use `JSON.parse` to parse the response body will fail with this error because the response body has already been parsed.

If the content-type response header is not `application/json`, the response body will not automatically be parsed and the `JSON.parse` function will still need to be used.

## Scripted API: HEAD or GET request cannot be used with a body

You cannot include a request body with a HTTP HEAD or GET request. The `request` module used by the Node 10 and older runtime allowed this, but this will cause errors in the new runtime. The error can be caused by a few different configurations, but the most common suggestions include:

* Do not include a body in your request, even if it is empty.
* Avoid unnecessary options on your HEAD or GET request, like `json: true`

## Scripted API: Query string (qs) differences

In the Node 10 or older runtimes, query string configurations were passed using the `qs:` option. For the Node 16 runtime, please use the `searchParams:` option instead. Only the name of the option needs to change. The content of the query string should not need to be updated.

## Scripted API: Cookie jar differences

In the Node 10 or older runtimes you could use the option `jar: true` to store cookies in a cookie jar between requests.

In the Node 16 runtime you must create a cookie jar using the `tough-cookie` module and then refer to that cookie jar in your request instead. If you created a cookie jar named cookies, refer to it in your options as `cookieJar: cookies`

## UUID Module Version Differences

The Node 16 runtime includes a newer version of the `uuid` module that forces the use of updated `require` syntax.

Node 10 and older:
`const uuid = require('uuid');`

Node 16 (assuming use of uuidv4):
`const { v4: uuidv4 } = require('uuid');`

## Scripted Browser: Deprecation warnings ($browser / $driver) [#deprecations]

Expand Down

0 comments on commit 8c0d5a8

Please sign in to comment.