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 to version 14 #83425

Merged
merged 14 commits into from
Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 12 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
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=12.19.1
ARG NODE_VERSION=14.15.1

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 @@
12.19.1
14.15.1
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.19.1
14.15.1
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"**/@types/hapi__boom": "^7.4.1",
"**/@types/hapi__hapi": "^18.2.6",
"**/@types/hapi__mimos": "4.1.0",
"**/@types/node": "12.19.4",
"**/@types/node": "14.14.7",
"**/cross-fetch/node-fetch": "^2.6.1",
"**/deepmerge": "^4.2.2",
"**/fast-deep-equal": "^3.1.1",
Expand All @@ -98,7 +98,7 @@
"**/typescript": "4.1.2"
},
"engines": {
"node": "12.19.1",
"node": "14.15.1",
"yarn": "^1.21.1"
},
"dependencies": {
Expand All @@ -109,7 +109,7 @@
"@elastic/ems-client": "7.11.0",
"@elastic/eui": "30.2.0",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "8.1.1-kibana2",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.0",
"@elastic/request-crypto": "1.1.4",
Expand Down Expand Up @@ -496,7 +496,7 @@
"@types/mustache": "^0.8.31",
"@types/ncp": "^2.0.1",
"@types/nock": "^10.0.3",
"@types/node": "12.19.4",
"@types/node": "14.14.7",
"@types/node-fetch": "^2.5.7",
"@types/node-forge": "^0.9.5",
"@types/nodemailer": "^6.4.0",
Expand Down Expand Up @@ -722,7 +722,7 @@
"less": "npm:@elastic/[email protected]",
"license-checker": "^16.0.0",
"listr": "^0.14.1",
"lmdb-store": "^0.8.15",
"lmdb-store": "^0.9.0",
"load-grunt-config": "^3.0.1",
"loader-utils": "^1.2.3",
"log-symbols": "^2.2.0",
Expand Down Expand Up @@ -805,7 +805,7 @@
"sass-resources-loader": "^2.0.1",
"selenium-webdriver": "^4.0.0-alpha.7",
"serve-static": "1.14.1",
"shelljs": "^0.8.3",
"shelljs": "^0.8.4",
"simple-git": "1.116.0",
"sinon": "^7.4.2",
"spawn-sync": "^1.0.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-legacy-logging/src/setup_logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

// @ts-expect-error missing typedef
import good from '@elastic/good';
import { plugin as good } from '@elastic/good';
import { Server } from '@hapi/hapi';
import { LegacyLoggingConfig } from './schema';
import { getLoggingConfiguration } from './get_logging_config';
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-pm/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
"@babel/proposal-object-rest-spread",
"@babel/proposal-optional-chaining"
mshustov marked this conversation as resolved.
Show resolved Hide resolved
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* tries to mock out simple versions of the Mocha types
*/

import EventEmitter from 'events';
import { EventEmitter } from 'events';

export interface Suite {
suites: Suite[];
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-utils/src/streams/reduce_stream.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('reduceStream', () => {
const errorStub = jest.fn();
reduce$.on('data', dataStub);
reduce$.on('error', errorStub);
const endEvent = promiseFromEvent('end', reduce$);
const closeEvent = promiseFromEvent('close', reduce$);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm somewhat concerned about this change. Looks like transform.destroy() is what leads to the close event being emitted, but we don't call it... any idea what change in node 14 lead to this being necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I must say I didn't go into too many details when debugging the test-failure, so I'm not sure my solution is correct. I'll take a closer look...


reduce$.write(1);
reduce$.write(2);
Expand All @@ -79,7 +79,7 @@ describe('reduceStream', () => {
reduce$.write(1000);
reduce$.end();

await endEvent;
await closeEvent;
expect(reducer).toHaveBeenCalledTimes(3);
expect(dataStub).toHaveBeenCalledTimes(0);
expect(errorStub).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion src/cli/cluster/cluster.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* eslint-env jest */

// eslint-disable-next-line max-classes-per-file
import EventEmitter from 'events';
import { EventEmitter } from 'events';
import { assign, random } from 'lodash';
import { delay } from 'bluebird';

Expand Down
19 changes: 12 additions & 7 deletions src/cli/repl/__snapshots__/repl.test.js.snap

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

2 changes: 1 addition & 1 deletion src/core/public/utils/crypto/sha256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Sha256 {
return this;
}

digest(encoding: string): string {
digest(encoding: BufferEncoding): string {
// Suppose the length of the message M, in bits, is l
const l = this._len * 8;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TransportRequestParams, RequestBody } from '@elastic/elasticsearch/lib/

import { parseClientOptionsMock, ClientMock } from './configure_client.test.mocks';
import { loggingSystemMock } from '../../logging/logging_system.mock';
import EventEmitter from 'events';
import { EventEmitter } from 'events';
import type { ElasticsearchClientConfig } from './client_config';
import { configureClient } from './configure_client';

Expand Down
1 change: 1 addition & 0 deletions src/core/server/metrics/collectors/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('ProcessMetricsCollector', () => {
heapTotal,
heapUsed,
external: 0,
arrayBuffers: 0,
}));

jest.spyOn(v8, 'getHeapStatistics').mockImplementation(
Expand Down
16 changes: 8 additions & 8 deletions src/dev/build/tasks/patch_native_modules_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ const packages: Package[] = [
extractMethod: 'gunzip',
archives: {
'darwin-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/darwin-x64-72.gz',
sha256: '983106049bb86e21b7f823144b2b83e3f1408217401879b3cde0312c803512c9',
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/darwin-x64-83.gz',
sha256: 'b45cd8296fd6eb2a091399c20111af43093ba30c99ed9e5d969278f5ff69ba8f',
},
'linux-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/linux-x64-72.gz',
sha256: '8b6692037f7b0df24dabc9c9b039038d1c3a3110f62121616b406c482169710a',
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/linux-x64-83.gz',
sha256: '1bbc3f90f0ba105772b37c04e3a718f69544b4df01dda00435c2b8e50b2ad0d9',
},

// ARM build is currently done manually as Github Actions used in upstream project
Expand All @@ -66,12 +66,12 @@ const packages: Package[] = [
// * upload to kibana-ci-proxy-cache bucket
'linux-arm64': {
url:
'https://storage.googleapis.com/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.15.4/linux-arm64-72.gz',
sha256: '5942353ec9cf46a39199818d474f7af137cfbb1bc5727047fe22f31f36602a7e',
'https://storage.googleapis.com/kibana-ci-proxy-cache/node-re2/uhop/node-re2/releases/download/1.15.4/linux-arm64-83.gz',
sha256: '4eb524ca9a79dea9c07342e487fbe91591166fdbc022ae987104840df948a4e9',
},
watson marked this conversation as resolved.
Show resolved Hide resolved
'win32-x64': {
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/win32-x64-72.gz',
sha256: '0a6991e693577160c3e9a3f196bd2518368c52d920af331a1a183313e0175604',
url: 'https://github.com/uhop/node-re2/releases/download/1.15.4/win32-x64-83.gz',
sha256: 'efe939d3cda1d64ee3ee3e60a20613b95166d55632e702c670763ea7e69fca06',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function replaceUrlQuery(
queryReplacer: (query: ParsedQuery) => ParsedQuery
) {
const url = parseUrl(rawUrl);
// @ts-expect-error `queryReplacer` expects key/value pairs with values of type `string | string[] | null`,
// however `@types/node` says that `url.query` has values of type `string | string[] | undefined`.
// After investigating this, it seems that no matter what the values will be of type `string | string[]`
const newQuery = queryReplacer(url.query || {});
Comment on lines 29 to 33
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

const searchQueryString = stringify(urlUtils.encodeQuery(newQuery), {
sort: false,
Expand All @@ -45,6 +48,9 @@ export function replaceUrlHashQuery(
) {
const url = parseUrl(rawUrl);
const hash = parseUrlHash(rawUrl);
// @ts-expect-error `queryReplacer` expects key/value pairs with values of type `string | string[] | null`,
// however `@types/node` says that `url.query` has values of type `string | string[] | undefined`.
// After investigating this, it seems that no matter what the values will be of type `string | string[]`
const newQuery = queryReplacer(hash?.query || {});
const searchQueryString = stringify(urlUtils.encodeQuery(newQuery), {
sort: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,16 @@ export function getRelativeToHistoryPath(absoluteUrl: string, history: History):

return formatUrl({
pathname: stripBasename(parsedUrl.pathname ?? null),
// @ts-expect-error `urlUtils.encodeQuery` expects key/value pairs with values of type `string | string[] | null`,
// however `@types/node` says that `url.query` has values of type `string | string[] | undefined`.
// After investigating this, it seems that no matter what the values will be of type `string | string[]`
search: stringify(urlUtils.encodeQuery(parsedUrl.query), { sort: false, encode: false }),
hash: parsedHash
? formatUrl({
pathname: parsedHash.pathname,
// @ts-expect-error `urlUtils.encodeQuery` expects key/value pairs with values of type `string | string[] | null`,
// however `@types/node` says that `url.query` has values of type `string | string[] | undefined`.
// After investigating this, it seems that no matter what the values will be of type `string | string[]`
search: stringify(urlUtils.encodeQuery(parsedHash.query), { sort: false, encode: false }),
})
: parsedUrl.hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export class LoginPage extends Component<Props, State> {
http={this.props.http}
notifications={this.props.notifications}
selector={selector}
// @ts-expect-error Map.get is ok with getting `undefined`
infoMessage={infoMessageMap.get(query[LOGOUT_REASON_QUERY_STRING_PARAMETER]?.toString())}
loginAssistanceMessage={this.props.loginAssistanceMessage}
loginHelp={loginHelp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ const normalizeTrustedAppsPageLocation = (
* @param query
* @param key
*/
export const extractFirstParamValue = (query: querystring.ParsedUrlQuery, key: string): string => {
export const extractFirstParamValue = (
query: querystring.ParsedUrlQuery,
key: string
): string | undefined => {
const value = query[key];

return Array.isArray(value) ? value[value.length - 1] : value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const uiQueryParams: (
typeof query[key] === 'string'
? (query[key] as string)
: Array.isArray(query[key])
? (query[key][query[key].length - 1] as string)
? (query[key] as string[])[(query[key] as string[]).length - 1]
: undefined;

if (value !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const getReadables = (dataPath: string): Promise<Readable> =>
const readable = fs.createReadStream(dataPath, { encoding: 'utf-8' });

readable.on('data', (stream) => {
contents.push(stream);
contents.push(stream as string);
});

readable.on('end', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { promisify } from 'bluebird';
import fs from 'fs';
import { promises as fs } from 'fs';
import path from 'path';
import { comparePngs } from '../../../../../../../test/functional/services/lib/compare_pngs';

const mkdirAsync = promisify<void, fs.PathLike, { recursive: boolean }>(fs.mkdir);

export async function checkIfPngsMatch(
actualpngPath: string,
baselinepngPath: string,
Expand All @@ -23,8 +20,8 @@ export async function checkIfPngsMatch(
const sessionDirectoryPath = path.resolve(screenshotsDirectory, 'session');
const failureDirectoryPath = path.resolve(screenshotsDirectory, 'failure');

await mkdirAsync(sessionDirectoryPath, { recursive: true });
await mkdirAsync(failureDirectoryPath, { recursive: true });
await fs.mkdir(sessionDirectoryPath, { recursive: true });
await fs.mkdir(failureDirectoryPath, { recursive: true });
jportner marked this conversation as resolved.
Show resolved Hide resolved

const actualpngFileName = path.basename(actualpngPath, '.png');
const baselinepngFileName = path.basename(baselinepngPath, '.png');
Expand All @@ -39,14 +36,14 @@ export async function checkIfPngsMatch(
// don't want to start causing failures for other devs working on OS's which are lacking snapshots. We have
// mac and linux covered which is better than nothing for now.
try {
log.debug(`writeFileSync: ${baselineCopyPath}`);
fs.writeFileSync(baselineCopyPath, fs.readFileSync(baselinepngPath));
log.debug(`writeFile: ${baselineCopyPath}`);
await fs.writeFile(baselineCopyPath, await fs.readFile(baselinepngPath));
} catch (error) {
log.error(`No baseline png found at ${baselinepngPath}`);
return 0;
}
log.debug(`writeFileSync: ${actualCopyPath}`);
fs.writeFileSync(actualCopyPath, fs.readFileSync(actualpngPath));
log.debug(`writeFile: ${actualCopyPath}`);
await fs.writeFile(actualCopyPath, await fs.readFile(actualpngPath));

let diffTotal = 0;

Expand Down
Loading