Skip to content

fix: Algolia scraper import json syntax #6226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

MikeMcC399
Copy link
Contributor

Situation

The CircleCI job "Run Algolia scraper" fails to run.

The error is

import config from './config.json' assert { type: 'json' }
                                   ^^^^^^

SyntaxError: Unexpected identifier 'assert'

Logs

See https://app.circleci.com/pipelines/github/cypress-io/cypress-documentation/26567/workflows/94363567-384d-4e59-9a5b-88987d84c5f1/jobs/67593

Scraping...
babel.config.js    docusaurus.config.js  patches      static
CONTRIBUTING.md    LICENSE.md            plugins      tailwind.config.js
cypress            netlify.toml          README.md    tsconfig.json
cypress.config.ts  node_modules          scripts      vercel.json
dist               package.json          sidebars.js
docs               package-lock.json     src
file:///home/circleci/repo/scripts/search/scrape-and-compare-algolia-index.mjs:26
import config from './config.json' assert { type: 'json' }
                                   ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:344:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:105:18)
    at #translate (node:internal/modules/esm/loader:534:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:581:27)
    at async ModuleJob._link (node:internal/modules/esm/module_job:116:19)

Node.js v22.15.1

Exited with code exit status 1

Assessment

import config from './config.json' assert { type: 'json' }

uses import ... assert { type: 'json' }

In Node.js 22.x only Import attributes are available. The experimental Import assertions from Node.js 18.17.1 are no longer supported. This was announced in the Node.js 22.0.0 release notes.

Change

In scripts/search/scrape-and-compare-algolia-index.mjs change from experimental Import assertions to Import attributes in the import statement for compatibility with Node.js 22.x:

import config from './config.json' with { type: 'json' }

Verification

Monitor the success of the CircleCI job "Run Algolia scraper" after PR merge into main branch.

Copy link

netlify bot commented Jul 17, 2025

👷 Deploy request for cypress-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 268c006

@cypress-app-bot
Copy link
Collaborator

@MikeMcC399 MikeMcC399 marked this pull request as ready for review July 17, 2025 05:27
@MikeMcC399
Copy link
Contributor Author

@AtofStryker

This should probably get fixed before the Cypress 15 docs release merge, otherwise Algolia is going to be using a stale index.

The recent Node.js update made one line of the scraper code incompatible and this blocks the whole scraper from running.

@AtofStryker AtofStryker self-requested a review July 18, 2025 14:00
@AtofStryker AtofStryker merged commit 3a428ac into cypress-io:main Jul 18, 2025
7 checks passed
@MikeMcC399
Copy link
Contributor Author

https://app.circleci.com/pipelines/github/cypress-io/cypress-documentation/26572/workflows/600d87a5-e6ac-45df-8369-d3253eb0a926/jobs/67615 shows that Algolia is able to run again 🎉 !

@MikeMcC399 MikeMcC399 deleted the fix/scraper-syntax branch July 18, 2025 14:37
@AtofStryker
Copy link
Contributor

@MikeMcC399 thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants