Skip to content

chore: Modernize codebase to node 22#40535

Merged
ggazzo merged 8 commits into
developfrom
chore/node22-modernization
May 19, 2026
Merged

chore: Modernize codebase to node 22#40535
ggazzo merged 8 commits into
developfrom
chore/node22-modernization

Conversation

@KevLehman
Copy link
Copy Markdown
Member

@KevLehman KevLehman commented May 14, 2026

Proposed changes (including videos or screenshots)

⏺ Adopt Node 22 / modern ES built-ins across server code

  1. Bump shared server lib to es2023

The shared @rocket.chat/tsconfig/server.json was pinned to lib: ["es2020"], even though every server package runs on Node 22. That mismatch hid ES2022/2023 APIs from
TypeScript and forced older idioms. Bumping only lib (target stays at es2020 to preserve class-field semantics) is a strict superset — no emitted JS changes — and is
the prerequisite for the rest of the commits.

  1. Object.hasOwn over hasOwnProperty

ES2022's Object.hasOwn(obj, key) is the standardized replacement for obj.hasOwnProperty(key). It avoids the prototype-pollution / shadowing footgun and works on
null-prototype objects (Object.create(null)) without the ugly Object.prototype.hasOwnProperty.call(...) workaround. Mechanical swap, identical semantics.

  1. Promise.allSettled + String.replaceAll
  • One Promise.all(...).catch(() => null) site that emulated allSettled is rewritten to use it directly — intent made explicit, behavior unchanged.
  • Two .replace(/literal/g, ...) calls with no regex features become .replaceAll('literal', ...) (ES2021), removing the need to scan the regex for metacharacters.
  1. crypto.randomUUID() over uuid.v4()

Six call sites used the uuid package solely to mint a random v4 UUID. Node has provided crypto.randomUUID() since 14.17 with identical RFC 4122 output and a more
specific return type. The federation Settings.ts site also collapses an old replace(new RegExp('-', 'g'), '') into .replaceAll('-', '').

  1. node: prefix on built-in imports

Sweep across 151 server-side files: from 'fs' → from 'node:fs', etc. Two motivations:

  • Disambiguation / supply-chain hygiene. The bare specifier 'fs' is first looked up as a userland module before falling back to the built-in; the node: prefix
    short-circuits resolution and refuses to find an imposter.
  • Forward compatibility. New built-ins like node:test and node:sqlite are only importable via the prefix; adopting it keeps the import style consistent.

Issue(s)

Steps to test or reproduce

Further comments

Task: CORE-2204

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 14, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Too many files!

This PR contains 158 files, which is 8 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9aea8f02-b0e4-4a75-aba7-d83e8b0cb641

📥 Commits

Reviewing files that changed from the base of the PR and between ebc9bab and 04865bf.

📒 Files selected for processing (158)
  • apps/meteor/app/2fa/server/code/index.ts
  • apps/meteor/app/api/server/definition.ts
  • apps/meteor/app/api/server/lib/MultipartUploadHandler.ts
  • apps/meteor/app/api/server/lib/getUploadFormData.ts
  • apps/meteor/app/api/server/middlewares/remoteAddressMiddleware.ts
  • apps/meteor/app/api/server/v1/misc.ts
  • apps/meteor/app/apps/server/bridges/listeners.ts
  • apps/meteor/app/apps/server/bridges/oauthApps.ts
  • apps/meteor/app/assets/server/assets.ts
  • apps/meteor/app/cors/server/cors.ts
  • apps/meteor/app/emoji-emojione/lib/generateEmojiIndex.mjs
  • apps/meteor/app/file-upload/lib/FileUploadBase.ts
  • apps/meteor/app/file-upload/server/config/AmazonS3.ts
  • apps/meteor/app/file-upload/server/config/FileSystem.ts
  • apps/meteor/app/file-upload/server/config/GoogleStorage.ts
  • apps/meteor/app/file-upload/server/config/GridFS.ts
  • apps/meteor/app/file-upload/server/config/helper.ts
  • apps/meteor/app/file-upload/server/lib/FileUpload.ts
  • apps/meteor/app/file-upload/server/lib/ranges.ts
  • apps/meteor/app/file-upload/server/lib/requests.ts
  • apps/meteor/app/file-upload/ufs/AmazonS3/server.ts
  • apps/meteor/app/file-upload/ufs/Webdav/server.ts
  • apps/meteor/app/file/server/file.server.ts
  • apps/meteor/app/file/server/functions/sanitizeFileName.ts
  • apps/meteor/app/importer-pending-files/server/PendingFileImporter.ts
  • apps/meteor/app/importer-slack-users/server/SlackUsersImporter.ts
  • apps/meteor/app/importer/server/methods/downloadPublicImportFile.ts
  • apps/meteor/app/importer/server/methods/getImportFileData.ts
  • apps/meteor/app/integrations/server/lib/isolated-vm/buildSandbox.ts
  • apps/meteor/app/irc/server/servers/RFC2813/index.js
  • apps/meteor/app/lib/server/functions/saveUser/setPasswordUpdater.ts
  • apps/meteor/app/lib/server/lib/validateEmailDomain.js
  • apps/meteor/app/lib/server/oauth/facebook.js
  • apps/meteor/app/livechat/server/lib/messages.ts
  • apps/meteor/app/livechat/server/livechat.ts
  • apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts
  • apps/meteor/app/meteor-accounts-saml/server/lib/ServiceProvider.ts
  • apps/meteor/app/meteor-accounts-saml/server/lib/Utils.ts
  • apps/meteor/app/meteor-accounts-saml/server/lib/signature/validateRedirectSignature.ts
  • apps/meteor/app/meteor-accounts-saml/server/listener.ts
  • apps/meteor/app/metrics/server/lib/collectMetrics.ts
  • apps/meteor/app/slackbridge/server/RocketAdapter.ts
  • apps/meteor/app/slackbridge/server/SlackAdapter.ts
  • apps/meteor/app/statistics/server/lib/statistics.ts
  • apps/meteor/app/theme/server/server.ts
  • apps/meteor/app/ui-master/server/inject.ts
  • apps/meteor/app/utils/server/functions/isDocker.ts
  • apps/meteor/app/version-check/server/functions/getNewUpdates.ts
  • apps/meteor/app/webdav/server/lib/webdavClientAdapter.ts
  • apps/meteor/ee/server/apps/orchestrator.js
  • apps/meteor/ee/server/apps/storage/AppFileSystemSourceStorage.ts
  • apps/meteor/ee/server/local-services/instance/service.ts
  • apps/meteor/server/configuration/configureBoilerplate.ts
  • apps/meteor/server/email/IMAPInterceptor.ts
  • apps/meteor/server/lib/cas/middleware.ts
  • apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts
  • apps/meteor/server/lib/dataExport/makeZipFile.ts
  • apps/meteor/server/lib/dataExport/processDataDownloads.spec.ts
  • apps/meteor/server/lib/dataExport/processDataDownloads.ts
  • apps/meteor/server/lib/dataExport/sendFile.ts
  • apps/meteor/server/lib/dataExport/uploadZipFile.ts
  • apps/meteor/server/lib/fileUtils.ts
  • apps/meteor/server/methods/requestDataDownload.ts
  • apps/meteor/server/routes/avatar/middlewares/auth.ts
  • apps/meteor/server/routes/avatar/middlewares/browserVersion.ts
  • apps/meteor/server/routes/avatar/room.ts
  • apps/meteor/server/routes/avatar/user.ts
  • apps/meteor/server/routes/avatar/utils.ts
  • apps/meteor/server/routes/i18n.ts
  • apps/meteor/server/routes/userDataDownload.ts
  • apps/meteor/server/services/banner/service.ts
  • apps/meteor/server/services/federation/Settings.ts
  • apps/meteor/server/services/image/service.ts
  • apps/meteor/server/services/messages/hooks/BeforeSaveJumpToMessage.ts
  • apps/meteor/server/services/nps/service.ts
  • apps/meteor/server/services/upload/service.ts
  • apps/meteor/server/settings/misc.ts
  • apps/meteor/server/startup/serverRunning.ts
  • apps/meteor/server/ufs/ufs-local.spec.ts
  • apps/meteor/server/ufs/ufs-local.ts
  • apps/meteor/server/ufs/ufs-methods.ts
  • apps/meteor/server/ufs/ufs-server.ts
  • apps/meteor/server/ufs/ufs-store.ts
  • apps/meteor/tests/unit/server/lib/dataExport/uploadZipFile.spec.ts
  • ee/packages/federation-matrix/src/api/_matrix/media.ts
  • ee/packages/federation-matrix/src/helpers/validateFederatedUsername.ts
  • ee/packages/federation-matrix/tests/end-to-end/messaging.spec.ts
  • ee/packages/federation-matrix/tests/helper/synapse-client.ts
  • ee/packages/license/src/AirGappedRestriction.ts
  • ee/packages/license/src/token.ts
  • ee/packages/license/src/validation/validateLicenseUrl.spec.ts
  • ee/packages/license/src/validation/validateLicenseUrl.ts
  • ee/packages/media-calls/src/internal/SignalProcessor.ts
  • ee/packages/media-calls/src/server/CallDirector.ts
  • ee/packages/media-calls/src/sip/Session.ts
  • ee/packages/network-broker/src/NetworkBroker.ts
  • ee/packages/omnichannel-services/src/OmnichannelTranscript.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/ChatTranscript.fixtures.ts
  • ee/packages/pdf-worker/src/templates/ChatTranscript/components/Files.tsx
  • ee/packages/pdf-worker/src/templates/ChatTranscript/index.tsx
  • ee/packages/pdf-worker/src/worker.fixtures.ts
  • ee/packages/presence/src/Presence.ts
  • packages/account-utils/src/index.ts
  • packages/agenda/src/Agenda.ts
  • packages/apps-engine/src/definition/oauth2/IOAuth2.ts
  • packages/apps-engine/src/definition/oauth2/OAuth2Client.ts
  • packages/apps/src/server/AppManager.ts
  • packages/apps/src/server/ProxiedApp.ts
  • packages/apps/src/server/accessors/LivechatCreator.ts
  • packages/apps/src/server/accessors/UploadCreator.ts
  • packages/apps/src/server/compiler/AppCompiler.ts
  • packages/apps/src/server/compiler/AppPackageParser.ts
  • packages/apps/src/server/compiler/modules/networking.ts
  • packages/apps/src/server/managers/AppSignatureManager.ts
  • packages/apps/src/server/marketplace/license/Crypto.ts
  • packages/apps/src/server/misc/UIHelper.ts
  • packages/apps/src/server/misc/Utilities.ts
  • packages/apps/src/server/runtime/AppsEngineNodeRuntime.ts
  • packages/apps/src/server/runtime/EmptyRuntime.ts
  • packages/apps/src/server/runtime/IRuntimeController.ts
  • packages/apps/src/server/runtime/deno/AppsEngineDenoRuntime.ts
  • packages/apps/src/server/runtime/deno/LivenessManager.ts
  • packages/apps/src/server/runtime/deno/ProcessMessenger.ts
  • packages/apps/src/server/runtime/deno/bundler.ts
  • packages/apps/tests/server/runtime/DenoRuntimeSubprocessController.test.ts
  • packages/apps/tests/server/runtime/SecureFieldsCodecCompatibility.test.ts
  • packages/apps/tests/server/runtime/deno/LivenessManager.test.ts
  • packages/apps/tests/test-data/utilities.ts
  • packages/cas-validate/src/validate.ts
  • packages/core-services/src/LocalBroker.ts
  • packages/core-services/src/types/IMediaService.ts
  • packages/core-services/src/types/IUploadService.ts
  • packages/core-services/src/types/ServiceClass.ts
  • packages/core-typings/src/IIncomingMessage.ts
  • packages/core-typings/src/IMessage/IMessage.ts
  • packages/core-typings/src/ISocketConnection.ts
  • packages/core-typings/src/IStats.ts
  • packages/ddp-client/__tests__/DDPSDK.spec.ts
  • packages/http-router/src/middlewares/honoAdapterForExpress.spec.ts
  • packages/http-router/src/middlewares/honoAdapterForExpress.ts
  • packages/instance-status/src/index.ts
  • packages/livechat/webpack.config.ts
  • packages/models/src/models/EmojiCustom.ts
  • packages/random/src/NodeRandomGenerator.ts
  • packages/release-action/src/bumpNextVersion.ts
  • packages/release-action/src/createNpmFile.ts
  • packages/release-action/src/getMetadata.ts
  • packages/release-action/src/index.ts
  • packages/release-action/src/publishRelease.ts
  • packages/release-action/src/updatePRDescription.ts
  • packages/release-action/src/utils.ts
  • packages/server-fetch/src/helpers.ts
  • packages/server-fetch/src/index.ts
  • packages/storybook-config/src/main.ts
  • packages/tools/src/getHeader.spec.ts
  • packages/tools/src/getHeader.ts
  • packages/tools/src/stream.ts
  • packages/tsconfig/server.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 14, 2026

⚠️ No Changeset found

Latest commit: 04865bf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread apps/meteor/app/api/server/lib/getUploadFormData.ts Outdated
Comment thread apps/meteor/app/file-upload/server/lib/FileUpload.ts Outdated
Comment thread apps/meteor/server/ufs/ufs-local.ts Outdated
Comment thread apps/meteor/server/ufs/ufs-server.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 83.63636% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.66%. Comparing base (ebc9bab) to head (04865bf).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40535      +/-   ##
===========================================
- Coverage    69.74%   69.66%   -0.08%     
===========================================
  Files         3322     3322              
  Lines       122773   122775       +2     
  Branches     21870    21896      +26     
===========================================
- Hits         85623    85533      -90     
- Misses       33807    33885      +78     
- Partials      3343     3357      +14     
Flag Coverage Δ
e2e 59.24% <ø> (-0.09%) ⬇️
e2e-api 46.25% <16.66%> (-0.95%) ⬇️
unit 70.36% <95.55%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tassoevan tassoevan force-pushed the chore/node22-modernization branch from ae42aba to 88c3f4c Compare May 18, 2026 18:18
@KevLehman KevLehman requested a review from tassoevan May 18, 2026 18:35
@tassoevan tassoevan force-pushed the chore/node22-modernization branch from 88c3f4c to faef962 Compare May 18, 2026 23:00
KevLehman added 8 commits May 19, 2026 10:13
Unlocks Node 22 built-ins (Object.hasOwn, toSorted, findLast, etc.).
Target kept at es2020 to preserve class-field semantics.
- authorization.getRoles: `.sort` → `.toSorted` (no in-place mutation)
- SignalProcessor.reactToUnknownCall: `Promise.all + .catch(()=>null)` → `Promise.allSettled`
- EmojiCustom.findByNameOrAlias / OmnichannelTranscript: literal-pattern `.replace(/x/g, ...)` → `.replaceAll('x', ...)`
6 server-side call sites drop the uuid lib in favor of Node's built-in
randomUUID(). Federation Settings also collapses the new RegExp('-','g')
into .replaceAll('-', '_').
Sweep across server-side packages: prefix `fs`, `path`, `crypto`,
`stream`, `http`, `util`, `events` and other Node builtins with
the `node:` protocol. Skipped client widget code under
`packages/livechat/src/` and compiled apps-engine output.
@tassoevan tassoevan force-pushed the chore/node22-modernization branch from faef962 to 04865bf Compare May 19, 2026 13:14
@KevLehman KevLehman marked this pull request as ready for review May 19, 2026 15:10
@KevLehman KevLehman requested review from a team as code owners May 19, 2026 15:11
@KevLehman
Copy link
Copy Markdown
Member Author

/jira CORE

@KevLehman KevLehman modified the milestone: 8.5.0 May 19, 2026
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label May 19, 2026
@tassoevan tassoevan added this to the 8.5.0 milestone May 19, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 19, 2026
@tassoevan tassoevan added this pull request to the merge queue May 19, 2026
@ggazzo ggazzo removed this pull request from the merge queue due to a manual request May 19, 2026
@ggazzo ggazzo merged commit a44b12e into develop May 19, 2026
73 of 77 checks passed
@ggazzo ggazzo deleted the chore/node22-modernization branch May 19, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants