Skip to content

Commit ca60f16

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 9d27023 commit ca60f16

File tree

38 files changed

+899
-213
lines changed

38 files changed

+899
-213
lines changed

.github/workflows/build_and_test_workflow.yml

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ jobs:
102102

103103
- name: Run unit tests with coverage
104104
id: unit-tests
105+
env:
106+
NODE_OPTIONS: --max-old-space-size=8192
105107
run: yarn test:jest:ci:coverage
106108

107109
- name: Run mocha tests with coverage

.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 '.'

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",
@@ -166,7 +166,7 @@
166166
"deep-freeze-strict": "^1.1.1",
167167
"del": "^6.1.1",
168168
"dns-sync": "^0.2.1",
169-
"elastic-apm-node": "^3.7.0",
169+
"elastic-apm-node": "^3.43.0",
170170
"elasticsearch": "^16.7.0",
171171
"http-aws-es": "6.0.0",
172172
"execa": "^4.0.2",
@@ -301,7 +301,7 @@
301301
"@types/mock-fs": "^4.10.0",
302302
"@types/moment-timezone": "^0.5.12",
303303
"@types/mustache": "^0.8.31",
304-
"@types/node": "^14.17.32",
304+
"@types/node": "18.11.18",
305305
"@types/node-forge": "^1.0.1",
306306
"@types/normalize-path": "^3.0.0",
307307
"@types/pegjs": "^0.10.1",
@@ -468,7 +468,7 @@
468468
"zlib": "^1.0.5"
469469
},
470470
"engines": {
471-
"node": "^14.20.1",
471+
"node": "^18.15.0",
472472
"yarn": "^1.22.10"
473473
}
474474
}

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-cross-platform/src/path.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import path from 'path';
77
import fs from 'fs';
8-
import { access, rmdir, mkdir, writeFile, symlink } from 'fs/promises';
8+
import { access, rm, mkdir, writeFile, symlink } from 'fs/promises';
99

1010
import {
1111
resolveToFullNameSync,
@@ -43,9 +43,9 @@ describe('Cross Platform', () => {
4343
try {
4444
// If leftover artifacts were found, get rid of them
4545
await access(tmpTestFolder);
46-
await rmdir(tmpTestFolder, { recursive: true });
46+
await rm(tmpTestFolder, { recursive: true });
4747
} catch (ex) {
48-
// Do nothing; if `rmdir` failed, let the `mkdir` below throw the error
48+
// Do nothing; if `rm` failed, let the `mkdir` below throw the error
4949
}
5050

5151
await mkdir(tmpTestFolder);
@@ -60,7 +60,7 @@ describe('Cross Platform', () => {
6060

6161
afterAll(async () => {
6262
try {
63-
await rmdir(tmpTestFolder, { recursive: true });
63+
await rm(tmpTestFolder, { recursive: true });
6464
} catch (ex) {
6565
// Do nothing
6666
}

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-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/integration_tests/basic_optimization.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ const TMP_DIR = Path.resolve(__dirname, '../__fixtures__/__tmp__');
5252
const MOCK_REPO_SRC = Path.resolve(__dirname, '../__fixtures__/mock_repo');
5353
const MOCK_REPO_DIR = Path.resolve(TMP_DIR, 'mock_repo');
5454

55+
jest.mock('lmdb', () => {
56+
const mockedLmdb = {
57+
open: jest.fn(() => ({
58+
openDB: jest.fn(() => ({
59+
get: jest.fn(),
60+
putSync: jest.fn(),
61+
remove: jest.fn(),
62+
})),
63+
})),
64+
};
65+
return mockedLmdb;
66+
});
67+
5568
expect.addSnapshotSerializer({
5669
serialize: (value: string) => value.split(REPO_ROOT).join('<absolute path>').replace(/\\/g, '/'),
5770
test: (value: any) => typeof value === 'string' && value.includes(REPO_ROOT),

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',

0 commit comments

Comments
 (0)