Skip to content
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

Upgrade Node.js from v16.18.1 to v18.13.0 #144012

Merged
merged 18 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .buildkite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .buildkite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"tslib": "*"
},
"devDependencies": {
"@types/chai": "^4.2.10",
"@types/chai": "^4.3.3",
"@types/js-yaml": "^4.0.5",
"@types/minimatch": "^3.0.5",
"@types/mocha": "^10.0.1",
"@types/node": "^15.12.2",
"chai": "^4.2.0",
"chai": "^4.3.6",
"mocha": "^10.2.0",
"nock": "^12.0.2",
"ts-node": "^10.7.0",
Expand Down
2 changes: 1 addition & 1 deletion .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable.
# If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts

ARG NODE_VERSION=16.18.1
ARG NODE_VERSION=18.13.0

FROM node:${NODE_VERSION} AS base

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.1
18.13.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.1
18.13.0
12 changes: 6 additions & 6 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install
# Setup the Node.js toolchain for the architectures we want to support
node_repositories(
node_repositories = {
"16.18.1-darwin_amd64": ("node-v16.18.1-darwin-x64.tar.gz", "node-v16.18.1-darwin-x64", "c190e106d4ac6177d1db3a5a739d39dd68bd276ba17f3d3c84039a93717e081e"),
"16.18.1-darwin_arm64": ("node-v16.18.1-darwin-arm64.tar.gz", "node-v16.18.1-darwin-arm64", "71720bb0a80cf158d8fdf492def08048befd953ad45e2458b1d095e32c612ba7"),
"16.18.1-linux_arm64": ("node-v16.18.1-linux-arm64.tar.xz", "node-v16.18.1-linux-arm64", "98d81a2d08f88646541d282b7ccc32429f8706ddcb30943fc3779ef9674ebb93"),
"16.18.1-linux_amd64": ("node-v16.18.1-linux-x64.tar.xz", "node-v16.18.1-linux-x64", "de2c694e7081c37022817d27a65b02f69ecf4c49699d65585e8e24431b7bc920"),
"16.18.1-windows_amd64": ("node-v16.18.1-win-x64.zip", "node-v16.18.1-win-x64", "db6a81de8e8ca3444495f1bcf04a883c076b4325d0fbaa032a190f88b38b30c5"),
"18.13.0-darwin_amd64": ("node-v18.13.0-darwin-x64.tar.gz", "node-v18.13.0-darwin-x64", "8b57c4da4ff6cca19d5ef7953f8816e3406d1508a2e4ee7f997984b3b1d11b77"),
"18.13.0-darwin_arm64": ("node-v18.13.0-darwin-arm64.tar.gz", "node-v18.13.0-darwin-arm64", "418d535e64dbcbd628715180c2de4ffcecb8a84b81f233c60e6ab9f0d795c249"),
"18.13.0-linux_arm64": ("node-v18.13.0-linux-arm64.tar.xz", "node-v18.13.0-linux-arm64", "5b338667822341d1ea3b18d5b37d442a655829b9eafdc5f9008f00b8451ac148"),
"18.13.0-linux_amd64": ("node-v18.13.0-linux-x64.tar.xz", "node-v18.13.0-linux-x64", "7f5d6922a91986ef059ba8a4396aa435440adacfe6fc6fab60a857c8f2cf5e7a"),
"18.13.0-windows_amd64": ("node-v18.13.0-win-x64.zip", "node-v18.13.0-win-x64", "29c99ad1167ddbd72f2b15e91b560e36ac785b1873ba6791ab50d9d62f1957e2"),
},
node_version = "16.18.1",
node_version = "18.13.0",
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
Expand Down
4 changes: 2 additions & 2 deletions docs/developer/advanced/upgrading-nodejs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ These files must be updated when upgrading Node.js:
If they are not, and the update is urgent, you can skip this file and update it later once Docker Hub has been updated.
- {kib-repo}blob/{branch}/.node-version[`.node-version`]
- {kib-repo}blob/{branch}/.nvmrc[`.nvmrc`]
- {kib-repo}blob/{branch}/package.json[`package.json`] - The version is specified in the `engines.node` field.
- {kib-repo}blob/{branch}/package.json[`package.json`] - The version is specified in the `engines.node` field (if possible, also upgrade `@types/node` to match the new version, both under `devDependencies` and `resolutions`).
- {kib-repo}blob/{branch}/WORKSPACE.bazel[`WORKSPACE.bazel`] - The version is specified in the `node_version` property.
Besides this property, the list of files under `node_repositories` must be updated along with their respective SHA256 hashes.
These can be found on the https://nodejs.org[nodejs.org] website.
Example for Node.js v16.18.1: https://nodejs.org/dist/v16.18.1/SHASUMS256.txt.asc
Example for Node.js v18.13.0: https://nodejs.org/dist/v18.13.0/SHASUMS256.txt.asc

See PR {kib-repo}pull/128123[#128123] for an example of how the Node.js version has been upgraded previously.

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
"url": "https://github.com/elastic/kibana.git"
},
"engines": {
"node": "16.18.1",
"node": "18.13.0",
"yarn": "^1.22.19"
},
"resolutions": {
"**/@types/node": "16.11.41",
"**/@types/node": "18.11.18",
"**/chokidar": "^3.5.3",
"**/deepmerge": "^4.2.2",
"**/fast-deep-equal": "^3.1.1",
Expand Down Expand Up @@ -622,7 +622,7 @@
"query-string": "^6.13.2",
"rbush": "^3.0.1",
"re-resizable": "^6.1.1",
"re2": "1.17.4",
"re2": "1.17.7",
"react": "^17.0.2",
"react-ace": "^7.0.5",
"react-beautiful-dnd": "^13.1.0",
Expand Down Expand Up @@ -683,7 +683,7 @@
"styled-components": "^5.1.0",
"suricata-sid-db": "^1.0.2",
"symbol-observable": "^1.2.0",
"tar": "^6.1.11",
"tar": "^6.1.13",
"tinycolor2": "1.4.1",
"tinygradient": "0.4.3",
"ts-easing": "^0.2.0",
Expand Down Expand Up @@ -936,7 +936,7 @@
"@types/multistream": "^4.1.0",
"@types/mustache": "^0.8.31",
"@types/nock": "^10.0.3",
"@types/node": "16.11.41",
"@types/node": "18.11.18",
"@types/node-fetch": "^2.6.0",
"@types/node-forge": "^1.3.1",
"@types/nodemailer": "^6.4.0",
Expand Down Expand Up @@ -983,7 +983,7 @@
"@types/styled-components": "^5.1.0",
"@types/supertest": "^2.0.5",
"@types/tapable": "^1.0.6",
"@types/tar": "^4.0.5",
"@types/tar": "^6.1.3",
"@types/tempy": "^0.2.0",
"@types/testing-library__jest-dom": "^5.14.5",
"@types/tinycolor2": "^1.4.1",
Expand Down Expand Up @@ -1158,7 +1158,7 @@
"simple-git": "^3.15.1",
"sinon": "^7.4.2",
"sort-package-json": "^1.53.1",
"source-map": "^0.7.3",
"source-map": "^0.7.4",
"string-replace-loader": "^2.2.0",
"style-loader": "^1.1.3",
"stylelint": "^14.9.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-i18n/src/core/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,13 @@ describe('I18n engine', () => {
i18n.translate('a.short', {
values: { expires: new Date(2018, 5, 20, 18, 40, 30, 50) },
} as any)
).toBe('Coupon expires at 6:40 PM');
).toBe('Coupon expires at 6:40PM');

expect(
i18n.translate('a.medium', {
values: { expires: new Date(2018, 5, 20, 18, 40, 30, 50) },
} as any)
).toBe('Coupon expires at 6:40:30 PM');
).toBe('Coupon expires at 6:40:30PM');
});

test('should format default messages with time formatter', () => {
Expand All @@ -679,14 +679,14 @@ describe('I18n engine', () => {
defaultMessage: 'Coupon expires at {expires, time, short}',
values: { expires: new Date(2018, 5, 20, 18, 40, 30, 50) },
})
).toBe('Coupon expires at 6:40 PM');
).toBe('Coupon expires at 6:40PM');

expect(
i18n.translate('foo', {
defaultMessage: 'Coupon expires at {expires, time, medium}',
values: { expires: new Date(2018, 5, 20, 18, 40, 30, 50) },
})
).toBe('Coupon expires at 6:40:30 PM');
).toBe('Coupon expires at 6:40:30PM');
});

test('should format message with a custom format', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-monaco/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ webpack_cli(
env = select({
"//:dist": {
"NODE_ENV": "production",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
"//conditions:default": {
"NODE_ENV": "development",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
}),
visibility = ["//visibility:public"],
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/src/optimizer/observe_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function usingWorkerProc<T>(config: OptimizerConfig, fn: (proc: ChildProcess) =>
(): ProcResource => {
const proc = fork(require.resolve('../worker/run_worker'), [], {
execArgv: [
'--openssl-legacy-provider',
`--require=@kbn/babel-register/install`,
...(inspectFlag && config.inspectWorkers
? [`${inspectFlag}=${inspectPortCounter++}`]
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-ui-shared-deps-npm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ webpack_cli(
env = select({
"//:dist": {
"NODE_ENV": "production",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
"//conditions:default": {
"NODE_ENV": "development",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
})
)
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-ui-shared-deps-src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ webpack_cli(
env = select({
"//:dist": {
"NODE_ENV": "production",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
"//conditions:default": {
"NODE_ENV": "development",
"NODE_OPTIONS": "--openssl-legacy-provider",
},
}),
visibility = ["//visibility:public"],
Expand Down
36 changes: 18 additions & 18 deletions src/dev/build/tasks/patch_native_modules_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,50 +41,50 @@ interface Package {
const packages: Package[] = [
{
name: 're2',
version: '1.17.4',
version: '1.17.7',
destinationPath: 'node_modules/re2/build/Release/re2.node',
extractMethod: 'gunzip',
archives: {
'darwin-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.4/darwin-x64-93.gz',
sha256: '9558c5cb39622e9b3653203e772b129d6c634e7dbd7af1b244352fc1d704601f',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-x64-108.gz',
sha256: '4ed378c5a7fe6134b717afe7642254aff1ed7a881cbcaa53a012ac3efab49f99',
},
'linux-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.4/linux-x64-93.gz',
sha256: '4d06747b266c75b6f7ced93977692c0586ce6a52924cabb569bd966378941aa1',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-x64-108.gz',
sha256: '197a617ca2965f220848561afed71ff6df653f6d79910cf38e866c84ab38a236',
},

// ARM builds are currently done manually as Github Actions used in upstream project
// do not natively support an ARM target.

// From a AWS Graviton instance running Ubuntu:
// * install build-essential package
// From an AWS Graviton instance running Ubuntu or a GCE T2A instance running Debian:
// * install build-essential package: `sudo apt-get update` + `sudo apt install build-essential`
// * install nvm and the node version used by the Kibana repository
// * `npm install re2@1.17.4`
// * `npm install re2@1.17.7`
// * re2 will build itself on install
// * `cp node_modules/re2/build/Release/re2.node > linux-arm64-$(node -e "console.log(process.versions.modules)")
// * `cp node_modules/re2/build/Release/re2.node linux-arm64-$(node -e "console.log(process.versions.modules)")`
// * `gzip linux-arm64-*`
// * capture the sha256 with: `shasum -a 256 linux-arm64-*`
// * upload the `linux-arm64-*.gz` artifact to the `yarn-prebuilt-assets` bucket in GCS using the correct version number
// * upload the `linux-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'linux-arm64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.4/linux-arm64-93.gz',
sha256: '25409584f76f3d6ed85463d84adf094eb6e256ed1cb0b754b95bcbda6691fc26',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/linux-arm64-108.gz',
sha256: 'a690087a1a1fd9887aac1abdab68d1992600e218be10783da6d3381cca950c1a',
},

// A similar process is necessary for building on ARM macs:
// * bootstrap and re2 will build itself on install
// * `cp node_modules/re2/build/Release/re2.node > darwin-arm64-$(node -e "console.log(process.versions.modules)")
// * `cp node_modules/re2/build/Release/re2.node darwin-arm64-$(node -e "console.log(process.versions.modules)")`
// * `gzip darwin-arm64-*`
// * capture the sha256 with: `shasum -a 256 darwin-arm64-*`
// * upload the `darwin-arm64-*.gz` artifact to the `yarn-prebuilt-assets` bucket in GCS using the correct version number
// * upload the `darwin-arm64-*.gz` artifact to the `yarn-prebuilt-artifacts` bucket in GCS using the correct version number
'darwin-arm64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.4/darwin-arm64-93.gz',
sha256: 'd4b708749ddef1c87019f6b80e051ed0c29ccd1de34f233c47d8dcaddf803872',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/darwin-arm64-108.gz',
sha256: '42afc32137ff5c5bebae5d68347a9786906748c2f28e06194d8950707f2ae90e',
},

'win32-x64': {
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.4/win32-x64-93.gz',
sha256: '0320d0c0385432944c6fb3c8c8fcd78d440ce5626f7618f9ec71d88e44820674',
url: 'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.17.7/win32-x64-108.gz',
sha256: 'ff72fe02de652262659c8e17e44a932f3c873362233756b40d1a97538d05de92',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ describe('requestOAuthClientCredentialsToken', () => {
"maxSockets": Infinity,
"maxTotalSockets": Infinity,
"options": Object {
"noDelay": true,
"path": null,
"rejectUnauthorized": true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('requestOAuthJWTToken', () => {
"maxSockets": Infinity,
"maxTotalSockets": Infinity,
"options": Object {
"noDelay": true,
"path": null,
"rejectUnauthorized": true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('requestOAuthToken', () => {
"maxSockets": Infinity,
"maxTotalSockets": Infinity,
"options": Object {
"noDelay": true,
"path": null,
"rejectUnauthorized": true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ describe('CurationsTable', () => {
expect(tableContent).toContain('mountains, valleys');

expect(tableContent).toContain('Last updated');
expect(tableContent).toContain('Jan 1, 1970 12:00 PM');
expect(tableContent).toContain('Jan 2, 1970 12:00 PM');
expect(tableContent).toContain('Jan 1, 1970 12:00PM');
expect(tableContent).toContain('Jan 2, 1970 12:00PM');
});

it('renders queries with curation links and curation suggestion badges', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('FormattedDateTime', () => {
const date = new Date('1970-01-01T12:00:00');
const wrapper = mountWithIntl(<FormattedDateTime date={date} />);

expect(wrapper.text()).toEqual('Jan 1, 1970 12:00 PM');
expect(wrapper.text()).toEqual('Jan 1, 1970 12:00PM');
});

it('does not render time if hideTime is passed', () => {
Expand Down
19 changes: 11 additions & 8 deletions x-pack/plugins/fleet/server/services/epm/archive/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { finished } from 'stream/promises';

import tar from 'tar';
import yauzl from 'yauzl';

Expand All @@ -16,19 +18,20 @@ export async function untarBuffer(
buffer: Buffer,
filter = (entry: ArchiveEntry): boolean => true,
onEntry = (entry: ArchiveEntry): void => {}
): Promise<unknown> {
) {
const deflatedStream = bufferToStream(buffer);
// use tar.list vs .extract to avoid writing to disk
const inflateStream = tar.list().on('entry', (entry: tar.FileStat) => {
const path = entry.header.path || '';
const inflateStream = tar.list().on('entry', (entry) => {
const path = entry.path || '';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accessing the path via the header works but isn't supported according to the types. Instead it seems that you're supposed to access it directly via the root path property where it's copied to in the constructor:

https://github.com/npm/node-tar/blob/26a496e5fa74eeaa0c3539511560fc181ef56557/lib/read-entry.js#L50

if (!filter({ path })) return;
streamToBuffer(entry).then((entryBuffer) => onEntry({ buffer: entryBuffer, path }));
streamToBuffer(entry as unknown as NodeJS.ReadableStream).then((entryBuffer) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

streamToBuffer expects a ReadableStream, but entry isn't one. The types seem to be a little to strict though and casting like this should appease TS.

onEntry({ buffer: entryBuffer, path })
);
});

return new Promise((resolve, reject) => {
inflateStream.on('end', resolve).on('error', reject);
deflatedStream.pipe(inflateStream);
});
deflatedStream.pipe(inflateStream);

await finished(inflateStream);
Comment on lines -28 to +34
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the types inflateStream will never emit an error event. I'm not sure if we can 100% trust this, but using finished instead of listening for end is normally better practice anyway, and by doing so we actually also get any error events that might occur (without having to work around TS telling us it's not happening).

}

export async function unzipBuffer(
Expand Down
Loading