Skip to content

[Node.js v20] Plugin Verification Meta Issue #9459

@kavilla

Description

@kavilla

Background

To maintain optimal performance and security:
OpenSearch Dashboards is upgrading from Node.js v18 to v20

With plans to deprecate explicit support for older versions of Node.js. The current version OpenSearch Dashboards will soon EOL so therefore we must upgrade.

Node.js Version End-of-Life Dates

  • Node.js 14 (LTS): Security support ended on April 30, 2023.
  • Node.js 16 (LTS): Security support ended on September 11, 2023.
  • Node.js 18 (LTS): Security support ends on April 30, 2025.
  • Node.js 20 (LTS): Security support ends on April 30, 2026.
  • Node.js 22 (LTS): Security support ends on April 30, 2027.

Recent plugin build and installation tests on the feature/node-2x branch have ✅PASSED✅.

OpenSearch Dashboards starts without issue under Node.js v20. However, plugin owners should verify their own plugins to ensure compatibility as soon as possible.

Timeline

We plan to merge this upgrade by the first week of March 2025. If no critical issues are reported by then, we will proceed with the upgrade. Please test and report any issues before this deadline.

Action Items

Recommended steps for plugin testing:

  1. Checkout the feature branch with OpenSearch Dashboards root directory
git checkout feature/node-2x
# Install Node v20 (ensure you have NVM installed)
nvm install
# Install yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
# Bootstrap OpenSearch Dashboards
yarn osd bootstrap --single-version=loose
# Start OpenSearch Dashboards
yarn start
  1. Run automated tests within your plugin.
  2. Perform manual functional testing to confirm everything works as expected.

Potential Issues

Node.js 20 Upgrade Issues and Solutions

Issue Description Solution
Deprecation Warnings Node.js v20 has stricter URL parsing rules, causing warnings for invalid URL formats in package.json dependencies Update URL format in package.json files (e.g., browserify-rsa#20)
Encoding Format Node.js v20.5.0+ no longer accepts 'utf-8' (with hyphen) for encoding Use 'utf8' (without hyphen) in all fs.readFileSync calls and similar functions
Stricter Type Checking Node.js 20 enforces stricter type comparisons Explicitly convert between types when making comparisons, especially in tests
Polyfill Conflicts resize-observer-polyfill 1.5.1 conflicts with TypeScript 4.6+ built-in types Use TypeScript 4.5.5 or update polyfill package
Type Definition Issues @types/lodash v4.17.16+ syntax causes errors Pin @types/lodash to version 4.14.165
Hapi Upgrade Challenges Upgrading Hapi framework will be difficult Consider removing Hapi dependency
Error Code Format Changes Error codes now include UV prefix (UV_EACCES vs EACCES) Update test expectations to handle new error formats
Future Upgrade Complexity More significant challenges expected with Node.js 22 upgrade Initial TypeScript upgrade efforts to 4.6+ had to be rolled back to 4.5.5; expect similar compatibility challenges with Node.js 22

Action Items

  1. Update Tests: Modify test expectations to handle new error message formats
  2. Verify Compression: Ensure brotli and gzip variants match raw data when testing file compression
  3. Update Encoding References: Use 'utf8' instead of 'utf-8' in:
    • HTML Meta Charset tags
    • MIME Types in Blob objects
    • Node.js Buffer encoding specifications
  4. Plan Incrementally: Recognize that Node.js 20 is just the first step, with Node.js 22 likely requiring more extensive refactoring
  5. Node 20 promise handling that Node 18 was quietly tolerating. Example:
dataSources.map((ds) => getDirectQueryConnections(ds.id, http!).catch(() => []))
  • 5.1. problems:
    • Silently swallowing errors with empty catch blocks
    • No timeout handling for network requests
    • Unbounded Promise.all operations assuming all promises resolve
    • Potential memory leaks from unmanaged promises
  • 5.2. temp solution:
    • I implemented this temporary fix to unblock CI:
      Promise.race([
        getDirectQueryConnections(ds.id, http!),
        new Promise((_, reject) => setTimeout(() => reject('timeout'), 5000))
      ])
  • 5.3: HOWEVER
    • this could be first of many similar issues.when Node 22 arrives, these patterns will become even more problematic

we can continue adding temporary solutions, but we might want to discuss a more sustainable approach before our technical debt becomes unmanageable.

Verification Checklist

Following the manifest order:


Thank you for your support and collaboration!

Metadata

Metadata

Assignees

Labels

Metanodejs 🍭issues related to nodejs client

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions