From 8c0d5a8b5af60104107a718971cceb9740d35983 Mon Sep 17 00:00:00 2001 From: Brian Peck Date: Thu, 19 Sep 2024 10:03:45 -0400 Subject: [PATCH] feat(RuntimeUpgrade): Added additional troubleshooting scenarios --- .../runtime-upgrade-troubleshooting.mdx | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/content/docs/synthetics/synthetic-monitoring/troubleshooting/runtime-upgrade-troubleshooting.mdx b/src/content/docs/synthetics/synthetic-monitoring/troubleshooting/runtime-upgrade-troubleshooting.mdx index 41ca4ec2903..ecd756c608e 100644 --- a/src/content/docs/synthetics/synthetic-monitoring/troubleshooting/runtime-upgrade-troubleshooting.mdx +++ b/src/content/docs/synthetics/synthetic-monitoring/troubleshooting/runtime-upgrade-troubleshooting.mdx @@ -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]