Synthetic browser tests are failing in Version 7.x

We are using 7.16.x ELK version in production and Dev environment and we are running heartbeat docker container v7.17.x for uptime monitoring. The http tests are working but the browser tests are failing with below error. Any work around to fix this issue without upgrading the ELK stack? We tried to upgrade heartbeat docker version to 8.x but thats not compatible with older Elastic search.

docker-elk-heartbeat-1 | 2023-01-31T17:04:55.059Z INFO synthexec/synthexec.go:260 stderr: /tmp/elastic-synthetics-2772323990/node_modules/@elastic/synthetics/dist/core/runner.js:184docker-elk-heartbeat-1 | 2023-01-31T17:04:55.060Z INFO synthexec/synthexec.go:260 stderr: data.url ??= page.url();docker-elk-heartbeat-1 | 2023-01-31T17:04:55.062Z INFO synthexec/synthexec.go:260 stderr: ^^^docker-elk-heartbeat-1 | 2023-01-31T17:04:55.062Z INFO synthexec/synthexec.go:260 stderr: docker-elk-heartbeat-1 | 2023-01-31T17:04:55.062Z INFO synthexec/synthexec.go:260 stderr: SyntaxError: Unexpected token '??='docker-elk-heartbeat-1 | 2023-01-31T17:04:55.063Z INFO synthexec/synthexec.go:260 stderr: at wrapSafe (internal/modules/cjs/loader.js:988:16)

Hi lawrance.ruban,

Syntax error suggests to me a potential version mismatch. You say you tried to upgrade heartbeat. Are you getting this error when you downgraded back down to the original version, or when you upgraded to version 8?

I am getting this error with ELK 7.16.x with heartbeat docker 7.17.x. I upgraded the heartbeat docker version to 8.x with allow_older_versions = true for elasticsearch in heartbeat.yml config but did not work still. We are getting this error only for browser tests with node package source.

I assume you're using the @elastic/synthetics package? Would version of that package are you using?

Yes the error is from @elastic/synthetics package. We are using @elastic/synthetics": "^1.0.0-beta version. We tried with multiple version within beta versions but didnt help.

Thanks for confirming. I've moved this topic to Uptime since the issue is with Synthetics rather than heartbeat.

@lawrance.ruban We have released a lot of code changes to the Synthetics package considering the 8.x stack improvements from Kibana and ES, so it would be possible that there is some breaking changes. Could you help with the following.

  1. What is the exact version of Heartbeat?
  2. Are you using Inline/Zip/Project based monitors? - Write a synthetic test | Observability Guide [8.6] | Elastic
  3. What is the exact version of Synthetics package? beta. ?
  4. Would be helpful if you can share your browser test to debug further.

Thanks in advance.

1 Like

ELK stack version : 7.16.3
Heartbeat docker version : 7.17.4
Synthetics version : ^1.0.0-beta.40 (tried different versions)
Monitor type : local type
heartbeat.yml

name: heartbeat
setup:
  template.enabled: false
  ilm.enabled: false

heartbeat.monitors:
  - type: browser
    id: elk-basic-test
    name: elk-basic-test
    schedule: '@every 1m'
    throttling: false
    tags:
      - app
    source:
      local:
        path: "${PWD}/config/lsm"
processors:
  - add_cloud_metadata: ~
monitoring:
  enabled: true
output.elasticsearch:
  hosts: [ http://elasticsearch:9200 ]
  username: heartbeat_internal
  password: ${HEARTBEAT_INTERNAL_PASSWORD}
  allow_older_versions: true
  ssl:
    verification_mode: none

package.json

{
  "name": "lsm",
  "version": "1.0.0",
  "description": "lsm synthetic testing",
  "scripts": {
    "test": "npx elastic-synthetics .",
    "debug": "npx elastic-synthetics --no-headless ."
  },
  "license": "ISC",
  "dependencies": {
    "@elastic/synthetics": "^1.0.0-beta.40",
    "playwright": "^1.30.0",
    "playwright-chromium": "^1.30.0",
    "sharp": "^0.30.1"
  }
}

demo.journey.ts

const { journey, step, expect } = require('@elastic/synthetics');
const URL = 'https://elastic-synthetics-demo-ecommerce.vercel.app/';

const navigateToProductDetail = (page, params) => {
  step('visit landing page', async () => {
    await page.goto(params.url || URL, { waitUntil: 'networkidle' });
    // check to make sure all products are loaded
    const productImages = await page.locator('.card img');
    expect(await productImages.count()).toBe(9);
  });

   step('navigate to product detail page', async () => {
      const productImages = await page.locator('.card img');
      const randomCard = Math.floor(
        Math.random() * (await productImages.count())
      );
      await Promise.all([
        page.waitForNavigation({ waitUntil: 'networkidle' }),
        productImages.nth(randomCard).click(),
      ]);
    });
  };

  journey(
    { name: 'Browse products and recommendations flow', tags: ['browse'] },
    ({ page, params }) => {
      navigateToProductDetail(page, params);

      step('look for recommendations', async () => {
        const recommendationsNode = await page.locator(
          'text=Products you might like'
        );
        await recommendationsNode.waitFor({ state: 'visible' });
        // Waits for recommendation product cards
        const recommendedProducts = await page.locator('.container .card');
        expect(await recommendedProducts.count()).toBe(4);
      });
    }
  );

Error :
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.798Z|INFO|synthexec/synthexec.go:153|Running command: /tmp/elastic-synthetics-2806849855/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-2806849855/node_modules/.bin/elastic-synthetics /tmp/elastic-synthetics-2806849855 --screenshots on --no-throttling --rich-events in directory: '/tmp/elastic-synthetics-2806849855'|
|---|---|---|---|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.973Z|INFO|synthexec/synthexec.go:260|stderr: /tmp/elastic-synthetics-2806849855/node_modules/@elastic/synthetics/dist/core/runner.js:184|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.973Z|INFO|synthexec/synthexec.go:260|stderr: data.url ??= page.url();|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: ^^^|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: |
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: SyntaxError: Unexpected token '??='|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: at wrapSafe (internal/modules/cjs/loader.js:988:16)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: at Module._compile (internal/modules/cjs/loader.js:1036:27)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: at Module.load (internal/modules/cjs/loader.js:937:32)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.974Z|INFO|synthexec/synthexec.go:260|stderr: at Function.Module._load (internal/modules/cjs/loader.js:778:12)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.975Z|INFO|synthexec/synthexec.go:260|stderr: at Module.require (internal/modules/cjs/loader.js:961:19)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.975Z|INFO|synthexec/synthexec.go:260|stderr: at require (internal/modules/cjs/helpers.js:92:18)|
|docker-elk-heartbeat-1 | 2023-02-02T17:29:26.975Z|INFO|synthexec/synthexec.go:260|stderr: at Object. (/tmp/elastic-synthetics-2806849855/node_modules/@elastic/synthetics/dist/core/index.js:32:34)|

Thanks for the detailed response.

The node version that the HB stack 7.17.x is running is 14.x which lacks some of the features and why we are seeing this SyntaxError.

I am checking if there is anyway we can backport this change. But unfortunately, you would have to wait for the next patch release of the Elastic Stack. The alternative option is to move to 8.x release version and try using projected based monitors - Create monitors with Project Monitors | Observability Guide [8.6] | Elastic which runs on our SAAS infrastructure.

Thanks,
Vignesh

@lawrance.ruban

Have you tried with older version of the Synthetics agent ?

"@elastic/synthetics": "=1.0.0-beta.38",

Something like this?

Thanks,
Vignesh

@vigneshshanmugam Thanks for the prompt response. Is there a workaround to use HB 8.x version with our existing ELK stack 7.16.x (runs on ELK SAAS infrastructure) or If we inject the newer Node version from our custom docker image to 7.17.x HB docker, will it work?

Tried other versions, Didnt try 38. Will try and see if that works.

Same error with 1.0.0-beta.38 also

Did you try pinning the exact version, meaning =1.0.0.beta.38 in your package.json file instead of ^1.0.0.beta-38?

If the above doesnt help, Does installing globally inside the image npm i -g @elastic/synthetics@v1.0.0-beta.38 help?

Thanks,
Vignesh

@vigneshshanmugam First of all thanks for the prompt response really appreciate it .The version 38 did not fix it. Actually older version 26 did the trick.

"@elastic/synthetics": "=1.0.0-beta.26",

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.