Skip to content

chore: migrate to Node 24 LTS, upgrade dependencies, and resolve environment issues - #1835

Open
Bernard2806 wants to merge 7 commits into
lowlighter:masterfrom
Bernard2806:master
Open

chore: migrate to Node 24 LTS, upgrade dependencies, and resolve environment issues#1835
Bernard2806 wants to merge 7 commits into
lowlighter:masterfrom
Bernard2806:master

Conversation

@Bernard2806

Copy link
Copy Markdown

Description

This PR upgrades the project runtime to Node 24 LTS (as Node 20 has reached its End of Life in April 2026), updates GitHub Actions workflows and npm packages to Node 24-compatible versions, and resolves several runtime/build environment issues introduced by the dependency upgrades.

Note

Although this PR modifies Workflow files (normally restricted under CONTRIBUTING.md) and Core dependencies, these changes are necessary to ensure the project remains compatible with supported Node.js runtimes and avoids security/deprecation issues associated with Node 20 EOL.

Why these changes were made

  1. Node 24 Migration & Dependency Upgrades: Upgrading to Node 24 LTS ensures the project stays on a supported, secure runtime environment. Consequently, dependencies like puppeteer, @octokit/*, and sharp were bumped to prevent deprecation and compatibility issues.
  2. Build and Compilation Dependencies: Upgrading the Docker base image and tools required installing supplementary compilation libraries (libxml2-dev, libxslt1-dev, xz-utils) to allow native compilation of the licensed Ruby gem dependencies.
  3. Module Interoperability (ESM): The updated @octokit/rest and @octokit/graphql dependencies modified their default ESM export behavior. This required switching from default imports to namespace imports to avoid runtime crashes.
  4. Resiliency and Bug Fixes:
    • Template Fallback (Backward Compatible): Resolved a rendering crash that occurred when a plugin failed. The classic template tried to call .includes() on sections which was undefined.
    • Puppeteer Path: Prevented Puppeteer startup errors inside the container because newer Puppeteer versions demand absolute executable paths (/usr/bin/google-chrome-stable instead of google-chrome-stable).

Detailed Changes

1. Upgrade to Node 24 LTS & Dependency Bumps (Workflows & Core)

  • Updated the Dockerfile base image to node:24-bookworm-slim.
  • Updated the node version to 24 across all .github/workflows/ files.
  • Upgraded several GitHub Actions in workflows (e.g., actions/checkout to v7, actions/setup-node to v6, github/codeql-action to v4).
  • Bumped major versions of puppeteer, sharp, jsdom, eslint, @actions/github, @octokit/graphql, and @octokit/rest in package.json.
  • Updated the postinstall script in package.json to utilize npx puppeteer browsers install chrome matching the new Puppeteer CLI syntax.

2. Docker Build & Setup Fixes

  • Dockerfile:
    • Added libxml2-dev and libxslt1-dev dependencies to support compilation of native XML/XSLT libraries for Ruby.
    • Added xz-utils to handle .tar.xz extractions during Ruby setup.
    • Updated PUPPETEER_BROWSER_PATH environment variable to use the absolute path /usr/bin/google-chrome-stable to prevent execution failure inside the Docker container.

3. Namespace Imports for @octokit (Core ESM compatibility)

Updated import statements from default to namespace imports (import * as ...) to maintain compatibility with @octokit/rest@21 and @octokit/graphql@8:

  • source/app/action/index.mjs
  • source/app/web/instance.mjs
  • source/app/metrics/setup.mjs
  • source/plugins/languages/analyzer/cli.mjs

4. Template Crash Fix (Templates)

  • source/templates/classic/partials/lines.ejs:
    • Added optional chaining (?.) to plugins.lines.sections on line 1. This prevents a TypeError when the plugin encounters an error and returns undefined for sections, allowing the template to safely handle the fallback error block without crashing the rendering process (visuals remain completely unchanged).

- Update Dockerfile base image from node:20 to node:24-bookworm-slim
- Update GitHub Actions to Node 24 compatible versions:
  - actions/checkout v3 → v7
  - actions/setup-node v3 → v6
  - github/codeql-action v2 → v4
  - actions/github-script v6 → v7
  - actions/labeler v4 → v6
  - actions/stale v6 → v10
  - dessant/lock-threads v4 → v6
- Update node-version from 20 to 24 in all workflow files
- Update npm dependencies for Node 24 compatibility:
  - puppeteer ^21.2.1 → ^25.0.0
  - sharp ^0.32.3 → ^0.35.0
  - jsdom ^22.1.0 → ^26.0.0
  - eslint ^8.49.0 → ^9.0.0
  - @actions/github ^5.1.1 → ^6.0.0
  - @octokit/graphql ^7.0.1 → ^8.0.0
  - @octokit/rest ^20.0.1 → ^21.0.0
- Fix postinstall script for Puppeteer v25 API changes

BREAKING CHANGE: Node 20 is no longer supported (EOL April 2026)
The lines plugin template (`lines.ejs`) was attempting to call `.includes()` on `plugins.lines.sections` at the very beginning of the file, before checking if the plugin had returned an error. If the plugin failed, `sections` was undefined, which resulted in a `TypeError` that crashed the entire rendering process.

This commit adds optional chaining (`?.`) to the `sections` property checks on line 1, allowing the template engine to safely bypass the condition when `sections` is missing and properly fall through to the internal `plugins.lines.error` handling block.
Recent versions of Puppeteer require `executablePath` to be an absolute path rather than just the executable name. This changes `PUPPETEER_BROWSER_PATH` from `google-chrome-stable` to `/usr/bin/google-chrome-stable` to resolve the "Browser was not found" error during the action run.
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.

1 participant