-
Notifications
You must be signed in to change notification settings - Fork 525
feat(cli): upgrade Node.js environment to version 22 #2033
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
base: main
Are you sure you want to change the base?
Conversation
- 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
There was a problem hiding this 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 enableskipLibCheckto address updated type surfaces. - Adjust Jest
process.exitmocks 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) => { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
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.
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { | |
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => { |
| fail: jest.fn(), | ||
| })) | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => { | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
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.
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { | |
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => { |
|
|
||
| // Mock process.exit | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => { | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
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.
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { | |
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => { |
| fail: jest.fn(), | ||
| })) | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: number) => { | ||
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { |
Copilot
AI
Feb 3, 2026
There was a problem hiding this comment.
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.
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: string | number | null) => { | |
| const mockExit = jest.spyOn(process, 'exit').mockImplementation((code?: Parameters<typeof process.exit>[0]) => { |
Summary
Upgrade CLI Node.js environment from version 18 to 22.
Changes
package.json:
engines.node: 18 → 22pkg.targets: node18-* → node22-* (all platforms)@types/node: ^17.0.43 → ^22.0.0.nvmrc: 18 → 22
tsconfig.json:
target: ES5 → ES2022lib: ESNext/ScriptHost/DOM → ES2022skipLibCheck: true to resolve type conflictsTest files: Fix
process.exitmock type for Node 22 compatibilityTest Plan
pubcommandsubcommandbench pubperformance testingbench subwith message rate statssimulatewith weather/tesla scenarios