Skip to content

Conversation

@ysfscream
Copy link
Member

Summary

Upgrade CLI Node.js environment from version 18 to 22.

Changes

  • package.json:

    • engines.node: 18 → 22
    • pkg.targets: node18-* → node22-* (all platforms)
    • @types/node: ^17.0.43 → ^22.0.0
  • .nvmrc: 18 → 22

  • tsconfig.json:

    • target: ES5 → ES2022
    • lib: ESNext/ScriptHost/DOM → ES2022
    • Add skipLibCheck: true to resolve type conflicts
  • Test files: Fix process.exit mock type for Node 22 compatibility

Test Plan

  • Build successful
  • All 243 tests pass (21 test suites)
  • Tested with broker.emqx.io:
    • pub command
    • sub command
    • bench pub performance testing
    • bench sub with message rate stats
    • simulate with weather/tesla scenarios
    • MQTT 5.0 features (QoS 2, retain, user properties)

- Update engines.node from 18 to 22 in package.json
- Update pkg targets from node18-* to node22-* for all platforms
- Update @types/node from ^17.0.43 to ^22.0.0
- Update .nvmrc from 18 to 22
- Update tsconfig.json: target ES5 -> ES2022, lib ES2022
- Add skipLibCheck to resolve type conflicts
- Fix process.exit mock type in test files for Node 22 compatibility

Tested with broker.emqx.io:
- pub/sub commands work correctly
- bench pub/sub performance testing works
- simulate command with weather/tesla scenarios works
- MQTT 5.0 features (QoS 2, retain, user properties) work
- All 243 tests pass
Copilot AI review requested due to automatic review settings February 3, 2026 06:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the CLI’s Node.js runtime/tooling baseline from Node 18 to Node 22, aligning TypeScript compilation settings and tests with the newer environment.

Changes:

  • Update CLI Node version requirements and packaging targets to Node 22.
  • Modernize CLI TypeScript compilation (target/lib) and enable skipLibCheck to address updated type surfaces.
  • Adjust Jest process.exit mocks for compatibility with updated Node type definitions.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli/package.json Bumps engines.node, pkg.targets, and @types/node to Node 22.
cli/.nvmrc Updates local Node version pin to 22.
cli/tsconfig.json Moves TS output to ES2022, narrows lib, adds node types, enables skipLibCheck.
cli/src/tests/utils/protobuf.test.ts Updates process.exit mock signature for Node 22 typing compatibility.
cli/src/tests/utils/parse.test.ts Updates process.exit mock signature for Node 22 typing compatibility.
cli/src/tests/utils/convertPayload.test.ts Updates process.exit mock signature for Node 22 typing compatibility.
cli/src/tests/utils/avro.test.ts Updates process.exit mock signature for Node 22 typing compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}))

const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mocked process.exit signature is hard-coded and may drift from Node’s type definitions over time. Prefer typing the argument from the real function (e.g., derive the parameter type from process.exit) so the spy implementation stays aligned across Node/@types upgrades.

Suggested change
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => {

Copilot uses AI. Check for mistakes.
fail: jest.fn(),
}))
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as other tests: avoid hard-coding the process.exit parameter union in the mock. Derive the parameter type from process.exit itself so future Node/@types updates don’t require touching this test.

Suggested change
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => {

Copilot uses AI. Check for mistakes.

// Mock process.exit
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider typing the mocked process.exit argument using the real function’s parameter type rather than a manually maintained union. This keeps the test resilient to changes in Node’s type definitions.

Suggested change
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => {

Copilot uses AI. Check for mistakes.
fail: jest.fn(),
}))
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The process.exit mock uses a manually specified union type for code. To reduce maintenance when Node/@types change, derive the code parameter type from process.exit instead of hard-coding it.

Suggested change
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => {
const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => {

Copilot uses AI. Check for mistakes.
@ysfscream ysfscream marked this pull request as draft February 3, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant