Skip to content

Commit

Permalink
Bump node.js from v14.20.1 to v18.12.0
Browse files Browse the repository at this point in the history
Revert "add node fiber to improve performance (opensearch-project#2319)"
Revert "[CVE-2022-25758] Use dart-sass instead of node-sass (opensearch-project#2054)"
Revert back to use node-sass and bump to 8.0.0
Bump node.js to 18 and fix errors

Signed-off-by: Anan Zhuang <ananzh@amazon.com>
  • Loading branch information
ananzh committed Mar 13, 2023
1 parent 7b18e06 commit 34a895e
Show file tree
Hide file tree
Showing 37 changed files with 472 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.15.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.21.3
18.15.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VERSION=14.20.1
ARG NODE_VERSION=18.15.0
FROM node:${NODE_VERSION} AS base

ENV HOME '.'
Expand Down
1 change: 1 addition & 0 deletions config/node.options
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

## max size of old space in megabytes
#--max-old-space-size=4096
--openssl-legacy-provider
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"test:jest:ci": "node scripts/jest --ci --colors --runInBand",
"test:jest:ci:coverage": "node scripts/jest --ci --colors --runInBand --coverage",
"test:jest_integration": "node scripts/jest_integration",
"test:jest_integration:ci": "node scripts/jest_integration --ci --colors --max-old-space-size=5120",
"test:jest_integration:ci": "node scripts/jest_integration --ci --colors --max-old-space-size=5120 --openssl-legacy-provider",
"test:mocha": "node scripts/mocha",
"test:mocha:coverage": "yarn nyc --reporter=text-summary --reporter=lcov --report-dir=./target/opensearch-dashboards-coverage/mocha node scripts/mocha",
"test:ftr": "node scripts/functional_tests",
Expand All @@ -60,7 +60,7 @@
"notice:generate": "node scripts/notice",
"build-platform": "node scripts/build",
"build": "node scripts/build --all-platforms",
"start": "node scripts/opensearch_dashboards --dev",
"start": "node --openssl-legacy-provider scripts/opensearch_dashboards --dev",
"start:docker": "node scripts/opensearch_dashboards --dev --opensearch.hosts=$OPENSEARCH_HOSTS --opensearch.ignoreVersionMismatch=true --server.host=$SERVER_HOST",
"debug": "node --nolazy --inspect scripts/opensearch_dashboards --dev",
"debug-break": "node --nolazy --inspect-brk scripts/opensearch_dashboards --dev",
Expand All @@ -71,8 +71,8 @@
"uiFramework:compileCss": "cd packages/osd-ui-framework && yarn compileCss",
"osd:watch": "node scripts/opensearch_dashboards --dev --logging.json=false",
"build:types": "node scripts/remove.js ./target/types && tsc --p tsconfig.types.json",
"docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept",
"osd:bootstrap": "node scripts/build_ts_refs && node scripts/register_git_hook",
"docs:acceptApiChanges": "node --max-old-space-size=6144 --openssl-legacy-provider scripts/check_published_api_changes.js --accept",
"osd:bootstrap": "export NODE_OPTIONS=--openssl-legacy-provider && node scripts/build_ts_refs && node scripts/register_git_hook",
"spec_to_console": "node scripts/spec_to_console",
"pkg-version": "node -e \"console.log(require('./package.json').version)\""
},
Expand All @@ -81,7 +81,7 @@
"url": "https://github.com/opensearch-project/opensearch-dashboards.git"
},
"resolutions": {
"**/@types/node": "^14.17.32",
"**/@types/node": "18.11.18",
"**/ansi-regex": "^5.0.1",
"**/async": "^3.2.3",
"**/d3-color": "^3.1.0",
Expand Down Expand Up @@ -300,7 +300,7 @@
"@types/mock-fs": "^4.10.0",
"@types/moment-timezone": "^0.5.12",
"@types/mustache": "^0.8.31",
"@types/node": "^14.17.32",
"@types/node": "18.11.18",
"@types/node-forge": "^1.0.1",
"@types/normalize-path": "^3.0.0",
"@types/pegjs": "^0.10.1",
Expand Down Expand Up @@ -467,7 +467,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "^14.20.1",
"node": "^18.15.0",
"yarn": "^1.22.10"
}
}
2 changes: 1 addition & 1 deletion packages/osd-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Env {
resolve(this.homeDir, 'src', 'plugins'),
resolve(this.homeDir, 'plugins'),
...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []),
resolve(this.homeDir, '..', 'opensearch-dashboards-extra'),
//resolve(this.homeDir, '..', 'opensearch-dashboards-extra'),
];

this.cliArgs = Object.freeze(options.cliArgs);
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-dev-utils/src/proc_runner/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
await withTimeout(
async () => {
log.debug(`Sending "${signal}" to proc "${name}"`);
await treeKillAsync(childProcess.pid, signal);
await treeKillAsync(childProcess.pid!, signal);
await outcomePromise;
},
STOP_TIMEOUT,
async () => {
log.warning(
`Proc "${name}" was sent "${signal}" didn't emit the "exit" or "error" events after ${STOP_TIMEOUT} ms, sending SIGKILL`
);
await treeKillAsync(childProcess.pid, 'SIGKILL');
await treeKillAsync(childProcess.pid!, 'SIGKILL');
}
);

Expand Down
2 changes: 1 addition & 1 deletion packages/osd-interpreter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"del": "^6.1.1",
"getopts": "^2.2.5",
"pegjs": "0.10.0",
"sass-loader": "^10.2.0",
"sass-loader": "^10.4.1",
"style-loader": "^1.1.3",
"supports-color": "^7.0.0",
"url-loader": "^2.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./target/index.js",
"license": "Apache-2.0",
"scripts": {
"build": "node ./scripts/build.js",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && node ./scripts/build.js",
"osd:bootstrap": "yarn build --dev"
},
"dependencies": {
Expand Down
9 changes: 5 additions & 4 deletions packages/osd-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
"dedent": "^0.7.0",
"del": "^6.1.1",
"execa": "^4.0.2",
"fibers": "^5.0.3",
"file-loader": "^4.2.0",
"jest-diff": "^27.5.1",
"js-yaml": "^3.14.0",
"json-stable-stringify": "^1.0.1",
"lmdb-store": "^1.6.11",
"lmdb": "^2.7.10",
"loader-utils": "^2.0.4",
"node-sass": "^8.0.0",
"normalize-path": "^3.0.0",
"pirates": "^4.0.1",
"postcss": "^8.4.5",
"rxjs": "^6.5.5",
"sass": "~1.26.11",
"source-map-support": "^0.5.19",
"terser-webpack-plugin": "^2.1.2",
"tinymath": "1.2.1",
Expand All @@ -54,7 +55,7 @@
"loader-utils": "^2.0.4",
"postcss-loader": "^4.2.0",
"raw-loader": "^4.0.2",
"sass-loader": "^10.2.0",
"sass-loader": "^10.4.1",
"style-loader": "^1.1.3",
"url-loader": "^2.2.0",
"val-loader": "^2.1.2",
Expand Down

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions packages/osd-optimizer/src/node/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import Path from 'path';
import { Writable } from 'stream';

import chalk from 'chalk';
import * as LmdbStore from 'lmdb-store';
import * as LmdbStore from 'lmdb';
import { getMatchingRoot } from '@osd/cross-platform';

const GLOBAL_ATIME = `${Date.now()}`;
Expand Down Expand Up @@ -96,8 +96,8 @@ export class Cache {
// keys which haven't been used in 30 days. We use `unref()` to
// make sure this timer doesn't hold other processes open
// unexpectedly
this.timer = setTimeout(() => {
this.pruneOldKeys();
this.timer = setTimeout(async () => {
await this.pruneOldKeys();
}, 30 * MINUTE);

// timer.unref is not defined in jest which emulates the dom by default
Expand Down Expand Up @@ -134,12 +134,13 @@ export class Cache {
async update(path: string, file: { mtime: string; code: string; map: any }) {
const key = this.getKey(path);

await Promise.all([
this.safePut(this.atimes, key, GLOBAL_ATIME),
this.safePut(this.mtimes, key, file.mtime),
this.safePut(this.codes, key, file.code),
this.safePut(this.sourceMaps, key, JSON.stringify(file.map)),
]);
this.safePut(this.atimes, key, GLOBAL_ATIME);
this.safePut(this.mtimes, key, file.mtime);
this.safePut(this.codes, key, file.code);

if (file.map != null) {
this.safePut(this.sourceMaps, key, JSON.stringify(file.map));
}
}

close() {
Expand Down Expand Up @@ -172,9 +173,9 @@ export class Cache {
}
}

private async safePut<V>(db: LmdbStore.Database<V, string>, key: string, value: V) {
private safePut<V>(db: LmdbStore.Database<V, string>, key: string, value: V) {
try {
await db.put(key, value);
db.putSync(key, value);
this.debug('PUT', db, key);
} catch (error) {
this.logError('PUT', db, key, error);
Expand Down Expand Up @@ -204,7 +205,6 @@ export class Cache {
const validKeys: string[] = [];
const invalidKeys: string[] = [];

// @ts-expect-error See https://github.com/DoctorEvidence/lmdb-store/pull/18
for (const { key, value } of this.atimes.getRange()) {
const atime = parseInt(`${value}`, 10);
if (Number.isNaN(atime) || atime < ATIME_LIMIT) {
Expand Down
1 change: 1 addition & 0 deletions packages/osd-optimizer/src/optimizer/observe_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function usingWorkerProc<T>(
? [`${inspectFlag}=${inspectPortCounter++}`]
: []),
...(config.maxWorkerCount <= 3 ? ['--max-old-space-size=2048'] : []),
'--openssl-legacy-provider',
],
buffer: false,
stderr: 'pipe',
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-optimizer/src/optimizer/optimizer_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class OptimizerConfig {
Path.resolve(repoRoot, 'src/plugins'),
Path.resolve(repoRoot, 'plugins'),
...(examples ? [Path.resolve('examples')] : []),
Path.resolve(repoRoot, 'opensearch-dashboards-extra'),
//Path.resolve(repoRoot, 'opensearch-dashboards-extra'),
];

if (!pluginScanDirs.every((p) => Path.isAbsolute(p))) {
Expand Down
5 changes: 2 additions & 3 deletions packages/osd-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,11 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
)};\n${content}`;
},
webpackImporter: false,
implementation: require('sass'),
implementation: require('node-sass'),
sassOptions: {
outputStyle: 'compressed',
outputStyle: 'nested',
includePaths: [Path.resolve(worker.repoRoot, 'node_modules')],
sourceMapRoot: `/${bundle.type}:${bundle.id}`,
fiber: require('fibers'),
},
},
},
Expand Down
7 changes: 3 additions & 4 deletions packages/osd-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27293,14 +27293,13 @@ function getProjectPaths({
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'examples/*'));

if (!skipOpenSearchDashboardsPlugins) {
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*'));
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*/packages/*'));
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*/plugins/*'));
//projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*'));
//projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*/packages/*'));
//projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, '../opensearch-dashboards-extra/*/plugins/*'));
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'plugins/*'));
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'plugins/*/packages/*'));
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'plugins/*/plugins/*'));
}

return projectPaths;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/osd-pm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/lodash": "^4.14.170",
"@types/log-symbols": "^2.0.0",
"@types/ncp": "^2.0.1",
"@types/node": "^14.17.32",
"@types/node": "18.11.18",
"@types/ora": "^1.3.5",
"@types/read-pkg": "^4.0.0",
"@types/strip-ansi": "^5.2.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/osd-pm/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export function getProjectPaths({ rootPath, ossOnly, skipOpenSearchDashboardsPlu
projectPaths.push(resolve(rootPath, 'examples/*'));

if (!skipOpenSearchDashboardsPlugins) {
projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*'));
projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*/packages/*'));
projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*/plugins/*'));
//projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*'));
//projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*/packages/*'));
//projectPaths.push(resolve(rootPath, '../opensearch-dashboards-extra/*/plugins/*'));
projectPaths.push(resolve(rootPath, 'plugins/*'));
projectPaths.push(resolve(rootPath, 'plugins/*/packages/*'));
projectPaths.push(resolve(rootPath, 'plugins/*/plugins/*'));
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* under the License.
*/

const sass = require('sass');
const sass = require('node-sass');
const postcss = require('postcss');
const postcssConfig = require('@osd/optimizer/postcss.config.js');

Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"grunt-babel": "^8.0.0",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
"sass": "~1.26.11",
"node-sass": "^8.0.0",
"postcss": "^8.4.5",
"sinon": "^7.4.2"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"private": true,
"license": "Apache-2.0",
"scripts": {
"build": "node scripts/build",
"osd:bootstrap": "node scripts/build --dev",
"build": "export NODE_OPTIONS=--openssl-legacy-provider && node scripts/build",
"osd:bootstrap": "export NODE_OPTIONS=--openssl-legacy-provider && node scripts/build --dev",
"osd:watch": "node scripts/build --dev --watch"
},
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion scripts/bwc/opensearch_dashboards_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function setup_dashboards() {
[ $SECURITY_ENABLED == "false" ] && echo "server.host: 0.0.0.0" >> config/opensearch_dashboards.yml
echo "csp.warnLegacyBrowsers: false" >> config/opensearch_dashboards.yml
echo "--max-old-space-size=5120" >> config/node.options
echo "--openssl-legacy-provider" >> config/node.options
}

# Starts OpenSearch Dashboards
Expand All @@ -29,4 +30,4 @@ function check_dashboards_status {
cd "$DIR"
check_status $DASHBOARDS_PATH "$DASHBOARDS_MSG" $DASHBOARDS_URL "$OPENSEARCH_ARGS" >> /dev/null 2>&1
echo "OpenSearch Dashboards is up!"
}
}
3 changes: 2 additions & 1 deletion src/core/public/plugins/plugins_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
// Setup each plugin with required and optional plugin contracts
const contracts = new Map<string, unknown>();
for (const [pluginName, plugin] of this.plugins.entries()) {
console.log(pluginName);
const pluginDepContracts = [...this.pluginDependencies.get(pluginName)!].reduce(
(depContracts, dependencyName) => {
// Only set if present. Could be absent if plugin does not have client-side code or is a
Expand All @@ -163,8 +164,8 @@ export class PluginsService implements CoreService<PluginsServiceSetup, PluginsS
errorMessage: `Start lifecycle of "${pluginName}" plugin wasn't completed in 30sec. Consider disabling the plugin and re-start.`,
});
contracts.set(pluginName, contract);
console.log(`${pluginName} done`);
}

// Expose start contracts
return { contracts };
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
*/

import chalk from 'chalk';
import { isMaster as isClusterManager } from 'cluster';
import cluster from 'cluster';
import { CliArgs, Env, RawConfigService } from './config';
import { Root } from './root';
import { CriticalError } from './errors';

let isClusterManager = cluster.isMaster;

interface OpenSearchDashboardsFeatures {
// Indicates whether we can run OpenSearch Dashboards in a so called cluster mode in which
// OpenSearch Dashboards is run as a "worker" process together with optimizer "worker" process
Expand Down Expand Up @@ -97,7 +99,7 @@ export async function bootstrap({
// in order to be able to reload the log configuration
// under the cluster mode
process.on('message', (msg) => {
if (!msg || msg.reloadLoggingConfig !== true) {
if (!msg || (msg as any).reloadLoggingConfig !== true) {
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/core/server/legacy/legacy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class LegacyService implements CoreService {
startDeps
);
}
this.log.debug('finished legacy service');
}

public async stop() {
Expand Down
7 changes: 4 additions & 3 deletions src/core/server/opensearch/opensearch_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,22 @@ export class OpenSearchService
};
}
public async start({ auditTrail }: StartDeps): Promise<InternalOpenSearchServiceStart> {
this.log.debug('I am here000');
this.auditorFactory = auditTrail;
if (!this.legacyClient || !this.createLegacyCustomClient) {
throw new Error('OpenSearchService needs to be setup before calling start');
}

this.log.debug('I am here111');
const config = await this.config$.pipe(first()).toPromise();

this.log.debug('I am here222');
const createClient = (
type: string,
clientConfig: Partial<OpenSearchClientConfig> = {}
): ICustomClusterClient => {
const finalConfig = merge({}, config, clientConfig);
return this.createClusterClient(type, finalConfig);
};

this.log.debug('I am here333');
return {
client: this.client!,
createClient,
Expand Down
Loading

0 comments on commit 34a895e

Please sign in to comment.