Skip to content

Commit d0f49c6

Browse files
committed
Bump node.js from v14.21.3 to v18.15.0
Revert "add node fiber to improve performance (#2319)" Revert "[CVE-2022-25758] Use dart-sass instead of node-sass (#2054)" Revert back to use node-sass and bump to 8.0.0 Change lmdb-store to lmdb Bump node.js to 18 and fix errors Issue Resolved: #3601 Signed-off-by: Anan Zhuang <ananzh@amazon.com>
1 parent 1e127b0 commit d0f49c6

File tree

29 files changed

+488
-162
lines changed

29 files changed

+488
-162
lines changed

.node-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.21.3
1+
18.15.0

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.21.3
1+
18.15.0

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG NODE_VERSION=14.20.1
1+
ARG NODE_VERSION=18.15.0
22
FROM node:${NODE_VERSION} AS base
33

44
ENV HOME '.'

config/node.options

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
## max size of old space in megabytes
66
#--max-old-space-size=4096
7+
--openssl-legacy-provider

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"url": "https://github.com/opensearch-project/opensearch-dashboards.git"
8282
},
8383
"resolutions": {
84-
"**/@types/node": "^14.17.32",
84+
"**/@types/node": "18.11.18",
8585
"**/ansi-regex": "^5.0.1",
8686
"**/async": "^3.2.3",
8787
"**/d3-color": "^3.1.0",
@@ -165,7 +165,7 @@
165165
"deep-freeze-strict": "^1.1.1",
166166
"del": "^6.1.1",
167167
"dns-sync": "^0.2.1",
168-
"elastic-apm-node": "^3.7.0",
168+
"elastic-apm-node": "^3.43.0",
169169
"elasticsearch": "^16.7.0",
170170
"http-aws-es": "6.0.0",
171171
"execa": "^4.0.2",
@@ -300,7 +300,7 @@
300300
"@types/mock-fs": "^4.10.0",
301301
"@types/moment-timezone": "^0.5.12",
302302
"@types/mustache": "^0.8.31",
303-
"@types/node": "^14.17.32",
303+
"@types/node": "18.11.18",
304304
"@types/node-forge": "^1.0.1",
305305
"@types/normalize-path": "^3.0.0",
306306
"@types/pegjs": "^0.10.1",
@@ -467,7 +467,7 @@
467467
"zlib": "^1.0.5"
468468
},
469469
"engines": {
470-
"node": "^14.20.1",
470+
"node": "^18.15.0",
471471
"yarn": "^1.22.10"
472472
}
473473
}

packages/osd-config-schema/src/errors/__snapshots__/schema_error.test.ts.snap

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/osd-dev-utils/src/proc_runner/proc.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
153153
await withTimeout(
154154
async () => {
155155
log.debug(`Sending "${signal}" to proc "${name}"`);
156-
await treeKillAsync(childProcess.pid, signal);
156+
await treeKillAsync(childProcess.pid!, signal);
157157
await outcomePromise;
158158
},
159159
STOP_TIMEOUT,
160160
async () => {
161161
log.warning(
162162
`Proc "${name}" was sent "${signal}" didn't emit the "exit" or "error" events after ${STOP_TIMEOUT} ms, sending SIGKILL`
163163
);
164-
await treeKillAsync(childProcess.pid, 'SIGKILL');
164+
await treeKillAsync(childProcess.pid!, 'SIGKILL');
165165
}
166166
);
167167

packages/osd-interpreter/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"del": "^6.1.1",
2828
"getopts": "^2.2.5",
2929
"pegjs": "0.10.0",
30-
"sass-loader": "^10.2.0",
30+
"sass-loader": "^10.4.1",
3131
"style-loader": "^1.1.3",
3232
"supports-color": "^7.0.0",
3333
"url-loader": "^2.2.0",

packages/osd-monaco/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "./target/index.js",
66
"license": "Apache-2.0",
77
"scripts": {
8-
"build": "node ./scripts/build.js",
8+
"build": "node ./scripts/build",
99
"osd:bootstrap": "yarn build --dev"
1010
},
1111
"dependencies": {

packages/osd-monaco/scripts/build.js

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ run(
4545

4646
const cwd = ROOT_DIR;
4747
const env = { ...process.env, dev: !!flags.dev, prod: !flags.dev };
48+
env.NODE_OPTIONS = '--openssl-legacy-provider';
49+
4850
if (supportsColor.stdout) {
4951
env.FORCE_COLOR = 'true';
5052
}

packages/osd-optimizer/package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@
2525
"dedent": "^0.7.0",
2626
"del": "^6.1.1",
2727
"execa": "^4.0.2",
28-
"fibers": "^5.0.3",
2928
"jest-diff": "^27.5.1",
3029
"js-yaml": "^3.14.0",
3130
"json-stable-stringify": "^1.0.1",
32-
"lmdb-store": "^1.6.11",
31+
"lmdb": "^2.7.10",
32+
"node-sass": "^8.0.0",
3333
"normalize-path": "^3.0.0",
3434
"pirates": "^4.0.1",
3535
"postcss": "^8.4.5",
3636
"rxjs": "^6.5.5",
37-
"sass": "~1.26.11",
3837
"source-map-support": "^0.5.19",
3938
"terser-webpack-plugin": "^2.1.2",
4039
"tinymath": "1.2.1",
@@ -54,7 +53,7 @@
5453
"loader-utils": "^2.0.4",
5554
"postcss-loader": "^4.2.0",
5655
"raw-loader": "^4.0.2",
57-
"sass-loader": "^10.2.0",
56+
"sass-loader": "^10.4.1",
5857
"style-loader": "^1.1.3",
5958
"url-loader": "^2.2.0",
6059
"val-loader": "^2.1.2",

packages/osd-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/osd-optimizer/src/node/cache.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import Path from 'path';
3232
import { Writable } from 'stream';
3333

3434
import chalk from 'chalk';
35-
import * as LmdbStore from 'lmdb-store';
35+
import * as LmdbStore from 'lmdb';
3636
import { getMatchingRoot } from '@osd/cross-platform';
3737

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

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

137-
await Promise.all([
138-
this.safePut(this.atimes, key, GLOBAL_ATIME),
139-
this.safePut(this.mtimes, key, file.mtime),
140-
this.safePut(this.codes, key, file.code),
141-
this.safePut(this.sourceMaps, key, JSON.stringify(file.map)),
142-
]);
137+
this.safePut(this.atimes, key, GLOBAL_ATIME);
138+
this.safePut(this.mtimes, key, file.mtime);
139+
this.safePut(this.codes, key, file.code);
140+
141+
if (file.map != null) {
142+
this.safePut(this.sourceMaps, key, JSON.stringify(file.map));
143+
}
143144
}
144145

145146
close() {
@@ -172,9 +173,9 @@ export class Cache {
172173
}
173174
}
174175

175-
private async safePut<V>(db: LmdbStore.Database<V, string>, key: string, value: V) {
176+
private safePut<V>(db: LmdbStore.Database<V, string>, key: string, value: V) {
176177
try {
177-
await db.put(key, value);
178+
db.putSync(key, value);
178179
this.debug('PUT', db, key);
179180
} catch (error) {
180181
this.logError('PUT', db, key, error);
@@ -204,7 +205,6 @@ export class Cache {
204205
const validKeys: string[] = [];
205206
const invalidKeys: string[] = [];
206207

207-
// @ts-expect-error See https://github.com/DoctorEvidence/lmdb-store/pull/18
208208
for (const { key, value } of this.atimes.getRange()) {
209209
const atime = parseInt(`${value}`, 10);
210210
if (Number.isNaN(atime) || atime < ATIME_LIMIT) {

packages/osd-optimizer/src/optimizer/observe_worker.ts

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function usingWorkerProc<T>(
8989
? [`${inspectFlag}=${inspectPortCounter++}`]
9090
: []),
9191
...(config.maxWorkerCount <= 3 ? ['--max-old-space-size=2048'] : []),
92+
'--openssl-legacy-provider',
9293
],
9394
buffer: false,
9495
stderr: 'pipe',

packages/osd-optimizer/src/optimizer/optimizer_config.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import Path from 'path';
3232
import Os from 'os';
33+
import { existsSync } from 'fs';
3334

3435
import {
3536
Bundle,
@@ -179,9 +180,12 @@ export class OptimizerConfig {
179180
Path.resolve(repoRoot, 'src/plugins'),
180181
Path.resolve(repoRoot, 'plugins'),
181182
...(examples ? [Path.resolve('examples')] : []),
182-
Path.resolve(repoRoot, 'opensearch-dashboards-extra'),
183183
];
184184

185+
if (existsSync(Path.resolve(repoRoot, 'opensearch-dashboards-extra'))) {
186+
pluginScanDirs.push(Path.resolve(repoRoot, 'opensearch-dashboards-extra'));
187+
}
188+
185189
if (!pluginScanDirs.every((p) => Path.isAbsolute(p))) {
186190
throw new TypeError('pluginScanDirs must all be absolute paths');
187191
}

packages/osd-optimizer/src/worker/webpack.config.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,11 @@ export function getWebpackConfig(bundle: Bundle, bundleRefs: BundleRefs, worker:
176176
)};\n${content}`;
177177
},
178178
webpackImporter: false,
179-
implementation: require('sass'),
179+
implementation: require('node-sass'),
180180
sassOptions: {
181-
outputStyle: 'compressed',
181+
outputStyle: 'nested',
182182
includePaths: [Path.resolve(worker.repoRoot, 'node_modules')],
183183
sourceMapRoot: `/${bundle.type}:${bundle.id}`,
184-
fiber: require('fibers'),
185184
},
186185
},
187186
},

packages/osd-pm/dist/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -27300,7 +27300,6 @@ function getProjectPaths({
2730027300
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'plugins/*/packages/*'));
2730127301
projectPaths.push(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'plugins/*/plugins/*'));
2730227302
}
27303-
2730427303
return projectPaths;
2730527304
}
2730627305

packages/osd-pm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@types/lodash": "^4.14.170",
2929
"@types/log-symbols": "^2.0.0",
3030
"@types/ncp": "^2.0.1",
31-
"@types/node": "^14.17.32",
31+
"@types/node": "18.11.18",
3232
"@types/ora": "^1.3.5",
3333
"@types/read-pkg": "^4.0.0",
3434
"@types/strip-ansi": "^5.2.1",

packages/osd-ui-framework/Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* under the License.
2929
*/
3030

31-
const sass = require('sass');
31+
const sass = require('node-sass');
3232
const postcss = require('postcss');
3333
const postcssConfig = require('@osd/optimizer/postcss.config.js');
3434

packages/osd-ui-framework/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"grunt-babel": "^8.0.0",
3131
"grunt-contrib-clean": "^2.0.0",
3232
"grunt-contrib-copy": "^1.0.0",
33-
"sass": "~1.26.11",
33+
"node-sass": "^8.0.0",
3434
"postcss": "^8.4.5",
3535
"sinon": "^7.4.2"
3636
}

packages/osd-ui-shared-deps/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"private": true,
55
"license": "Apache-2.0",
66
"scripts": {
7-
"build": "node scripts/build",
8-
"osd:bootstrap": "node scripts/build --dev",
7+
"build": "node --openssl-legacy-provider scripts/build",
8+
"osd:bootstrap": "node --openssl-legacy-provider scripts/build --dev",
99
"osd:watch": "node scripts/build --dev --watch"
1010
},
1111
"dependencies": {

scripts/bwc/opensearch_dashboards_service.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function setup_dashboards() {
1212
[ $SECURITY_ENABLED == "false" ] && echo "server.host: 0.0.0.0" >> config/opensearch_dashboards.yml
1313
echo "csp.warnLegacyBrowsers: false" >> config/opensearch_dashboards.yml
1414
echo "--max-old-space-size=5120" >> config/node.options
15+
echo "--openssl-legacy-provider" >> config/node.options
1516
}
1617

1718
# Starts OpenSearch Dashboards
@@ -29,4 +30,4 @@ function check_dashboards_status {
2930
cd "$DIR"
3031
check_status $DASHBOARDS_PATH "$DASHBOARDS_MSG" $DASHBOARDS_URL "$OPENSEARCH_ARGS" >> /dev/null 2>&1
3132
echo "OpenSearch Dashboards is up!"
32-
}
33+
}

src/core/server/bootstrap.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
*/
3030

3131
import chalk from 'chalk';
32-
import { isMaster as isClusterManager } from 'cluster';
32+
import cluster from 'cluster';
3333
import { CliArgs, Env, RawConfigService } from './config';
3434
import { Root } from './root';
3535
import { CriticalError } from './errors';
3636

37+
const isClusterManager = cluster.isMaster;
38+
3739
interface OpenSearchDashboardsFeatures {
3840
// Indicates whether we can run OpenSearch Dashboards in a so called cluster mode in which
3941
// OpenSearch Dashboards is run as a "worker" process together with optimizer "worker" process
@@ -97,7 +99,7 @@ export async function bootstrap({
9799
// in order to be able to reload the log configuration
98100
// under the cluster mode
99101
process.on('message', (msg) => {
100-
if (!msg || msg.reloadLoggingConfig !== true) {
102+
if (!msg || (msg as any).reloadLoggingConfig !== true) {
101103
return;
102104
}
103105

src/core/server/http/router/validator/validator.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('Router validator', () => {
7070
expect(() => validator.getParams({})).toThrowError('[foo]: Not a string');
7171

7272
expect(() => validator.getParams(undefined)).toThrowError(
73-
`Cannot read property 'foo' of undefined`
73+
`Cannot read properties of undefined (reading 'foo')`
7474
);
7575
expect(() => validator.getParams({}, 'myField')).toThrowError('[myField.foo]: Not a string');
7676

src/core/server/status/plugins_status.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interface Deps {
4343

4444
export class PluginsStatusService {
4545
private readonly pluginStatuses = new Map<PluginName, Observable<ServiceStatus>>();
46-
private readonly update$ = new BehaviorSubject(true);
46+
private readonly update$ = new BehaviorSubject<boolean>(true);
4747
private readonly defaultInheritedStatus$: Observable<ServiceStatus>;
4848

4949
constructor(private readonly deps: Deps) {
@@ -121,7 +121,7 @@ export class PluginsStatusService {
121121

122122
return combineLatest(pluginStatuses).pipe(
123123
map((statuses) => Object.fromEntries(statuses)),
124-
distinctUntilChanged(isDeepStrictEqual)
124+
distinctUntilChanged<Record<PluginName, ServiceStatus>>(isDeepStrictEqual)
125125
);
126126
})
127127
);

src/core/server/status/status_service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
9595
this.logger.debug(`Recalculated overall status`, { status: summary });
9696
return summary;
9797
}),
98-
distinctUntilChanged(isDeepStrictEqual),
98+
distinctUntilChanged<ServiceStatus<unknown>>(isDeepStrictEqual),
9999
shareReplay(1)
100100
);
101101

@@ -149,7 +149,7 @@ export class StatusService implements CoreService<InternalStatusServiceSetup> {
149149
opensearch: opensearchStatus,
150150
savedObjects: savedObjectsStatus,
151151
})),
152-
distinctUntilChanged(isDeepStrictEqual),
152+
distinctUntilChanged<CoreStatus>(isDeepStrictEqual),
153153
shareReplay(1)
154154
);
155155
}

src/dev/ci_setup/setup_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cacheDir="$HOME/.opensearch_dashboards"
2525
RED='\033[0;31m'
2626
C_RESET='\033[0m' # Reset color
2727

28-
export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096"
28+
export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096 --openssl-legacy-provider"
2929

3030
###
3131
### Since the Jenkins logging output collector doesn't look like a TTY

src/plugins/visualizations/server/saved_objects/visualization_migrations.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ describe('migration visualization', () => {
10031003
`);
10041004
expect(logMsgArr).toMatchInlineSnapshot(`
10051005
Array [
1006-
"Exception @ migrateGaugeVerticalSplitToAlignment! TypeError: Cannot read property 'gauge' of undefined",
1006+
"Exception @ migrateGaugeVerticalSplitToAlignment! TypeError: Cannot read properties of undefined (reading 'gauge')",
10071007
"Exception @ migrateGaugeVerticalSplitToAlignment! Payload: {\\"type\\":\\"gauge\\"}",
10081008
]
10091009
`);

0 commit comments

Comments
 (0)