Skip to content

Commit 2d31490

Browse files
repo: upgrade from node 16 to node >=18 (#12711)
The commit includes the following changes: - update deps for node 18.x - update breaking changes - update workflows - make sure node-gyp is installed - update logger tests - update docs - force ipv4 and improve ipv6 support - fix backend address messaging - update backend cli options - update runtime policy - fix backend cli - use node 18.x in gitpod image - keep using node 16.x in workflow Using Node 20.x it seems like Yarn complains about missing `node-gyp`. It will actually shortcut the first call to `yarn install` when it is missing in order to automatically install it. Instead we'll explicitly make sure that node-gyp is installed.
1 parent 9001508 commit 2d31490

File tree

19 files changed

+85
-73
lines changed

19 files changed

+85
-73
lines changed

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v3
2222

23-
- name: Use Node.js 16.x
23+
- name: Use Node.js 18.x
2424
uses: actions/setup-node@v3
2525
with:
26-
node-version: 16.x
26+
node-version: 18.x
2727
registry-url: 'https://registry.npmjs.org'
2828

2929
- name: Use Python 3.x
@@ -34,6 +34,7 @@ jobs:
3434
- name: Install and Build
3535
shell: bash
3636
run: |
37+
yarn global add node-gyp
3738
yarn --skip-integrity-check --network-timeout 100000
3839
./scripts/check_git_status.sh
3940
env:
@@ -51,7 +52,7 @@ jobs:
5152
fail-fast: false
5253
matrix:
5354
os: [windows-2019, ubuntu-latest, macos-11]
54-
node: [16.x]
55+
node: [16.x, 18.x, 20.x]
5556

5657
runs-on: ${{ matrix.os }}
5758
timeout-minutes: 60
@@ -74,6 +75,7 @@ jobs:
7475
- name: Install
7576
shell: bash
7677
run: |
78+
yarn global add node-gyp
7779
yarn --skip-integrity-check --network-timeout 100000
7880
./scripts/check_git_status.sh
7981
env:

.github/workflows/license-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
node: ['16.x']
23+
node: ['18.x']
2424
java: ['11']
2525

2626
runs-on: ${{ matrix.os }}

.github/workflows/performance-tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ on:
66
jobs:
77
build-and-test-performance:
88
name: Performance Tests
9-
9+
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 30
1212

1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v3
1616

17-
- name: Use Node.js 16.x
17+
- name: Use Node.js 18.x
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: "16.x"
20+
node-version: "18.x"
2121
registry-url: "https://registry.npmjs.org"
2222

2323
- name: Use Python 3.x
@@ -28,6 +28,7 @@ jobs:
2828
- name: Build
2929
shell: bash
3030
run: |
31+
yarn global add node-gyp
3132
yarn --skip-integrity-check --network-timeout 100000 --ignore-engines
3233
yarn build:examples
3334
env:

.github/workflows/playwright.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
build-and-test-playwright:
16-
name: Playwright Tests (ubuntu-latest, Node.js 16.x)
16+
name: Playwright Tests (ubuntu-latest, Node.js 18.x)
1717

1818
runs-on: ubuntu-latest
1919
timeout-minutes: 60
@@ -22,10 +22,10 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v3
2424

25-
- name: Use Node.js "16.x"
25+
- name: Use Node.js "18.x"
2626
uses: actions/setup-node@v3
2727
with:
28-
node-version: "16.x"
28+
node-version: "18.x"
2929
registry-url: "https://registry.npmjs.org"
3030

3131
- name: Use Python 3.x
@@ -36,6 +36,7 @@ jobs:
3636
- name: Build Browser
3737
shell: bash
3838
run: |
39+
yarn global add node-gyp
3940
yarn --skip-integrity-check --network-timeout 100000
4041
yarn browser build
4142
env:

.github/workflows/publish-gh-pages.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
with:
2020
fetch-depth: 0 # To fetch all history for all branches and tags. (Will be required for caching with lerna: https://github.com/markuplint/markuplint/pull/111)
2121

22-
- name: Use Node.js 16.x
22+
- name: Use Node.js 18.x
2323
uses: actions/setup-node@v3
2424
with:
25-
node-version: '16.x'
25+
node-version: '18.x'
2626
registry-url: 'https://registry.npmjs.org'
2727

2828
- name: Use Python 3.x
@@ -32,6 +32,7 @@ jobs:
3232

3333
- name: Pre-npm-Publish
3434
run: |
35+
yarn global add node-gyp
3536
yarn --skip-integrity-check --network-timeout 100000
3637
env:
3738
NODE_OPTIONS: --max_old_space_size=4096

.github/workflows/translation.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v3
1414

15-
- name: Use Node.js 16.x
15+
- name: Use Node.js 18.x
1616
uses: actions/setup-node@v3
1717
with:
18-
node-version: 16.x
18+
node-version: 18.x
1919
registry-url: "https://registry.npmjs.org"
2020

2121
- name: Use Python 3.x
@@ -26,6 +26,7 @@ jobs:
2626
- name: Install and Build
2727
shell: bash
2828
run: |
29+
yarn global add node-gyp
2930
yarn --skip-integrity-check --network-timeout 100000
3031
env:
3132
NODE_OPTIONS: --max_old_space_size=4096

.gitpod.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN sudo apt-get update \
1717

1818
ENV SHELL=/bin/bash
1919

20-
ENV NODE_VERSION="16.14.0"
20+
ENV NODE_VERSION="18.17.0"
2121
RUN bash -c ". .nvm/nvm.sh \
2222
&& nvm install $NODE_VERSION \
2323
&& nvm use $NODE_VERSION \

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
## History
44

55
- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)
6-
## v1.41.0 -
6+
7+
## v1.41.0
8+
79
- [application-package] Quit Electron app when back end fails to start [#12778](https://github.com/eclipse-theia/theia/pull/12778) - Contributed on behalf of STMicroelectronics.
810
- [vscode] added support for tree checkbox api [#12836](https://github.com/eclipse-theia/theia/pull/12836) - Contributed on behalf of STMicroelectronics
11+
- [core] Add `--dnsDefaultResultOrder <value>` CLI argument where `value` is one of `ipv4first`, `verbatim` or `nodeDefault`. It controls how domain names are resolved.
12+
13+
<a name="breaking_changes_1.41.0">[Breaking Changes:](#breaking_changes_1.41.0)</a>
14+
15+
- [deps] Bumped supported Node.js version from 16.x to >=18, you may need to update your environments.
16+
917
## v1.40.0 - 07/27/2023
1018

1119
- [application-package] bumped the default supported VS Code API from `1.78.0` to `1.79.0` [#12764](https://github.com/eclipse-theia/theia/pull/12764) - Contributed on behalf of STMicroelectronics.

dev-packages/application-manager/src/generator/backend-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ BackendApplicationConfigProvider.set(${this.prettyStringify(this.pck.props.backe
161161
const serverModule = require('./server');
162162
const serverAddress = main.start(serverModule());
163163
164-
serverAddress.then(({ port, address }) => {
164+
serverAddress.then(({ port, address, family }) => {
165165
if (process && process.send) {
166-
process.send({ port, address });
166+
process.send({ port, address, family });
167167
}
168168
});
169169

dev-packages/cli/src/run-test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ export default async function runTest(options: TestOptions): Promise<void> {
7979
}
8080
}
8181
});
82-
83-
const server = await start();
84-
await testPage.goto(`http://${server.address}:${server.port}`);
82+
const { address, port } = await start();
83+
const url = net.isIPv6(address)
84+
? `http://[${address}]:${port}`
85+
: `http://${address}:${port}`;
86+
await testPage.goto(url);
8587
}

doc/Developing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ For Windows instructions [click here](#building-on-windows).
5252

5353
## Prerequisites
5454

55-
- Node.js `>= 16.14.0` and `< 17`.
55+
- Node.js `>= 18.17.0` and `< 21`.
5656
- If you are interested in Theia's VS Code Extension support then you should use a Node version at least compatible with the one included in the version of Electron used by [VS Code](https://github.com/microsoft/vscode).
5757
- [Yarn package manager](https://yarnpkg.com/en/docs/install) `>= 1.7.0` **AND** `< 2.x.x`.
5858
- git (If you would like to use the Git-extension too, you will need to have git version 2.11.0 or higher.)
@@ -508,7 +508,7 @@ etc.) by opening `packages/<package name>/coverage/index.html`.
508508

509509
- Install [`scoop`](https://github.com/lukesampson/scoop#installation).
510510
- Install [`nvm`](https://github.com/coreybutler/nvm-windows) with scoop: `scoop install nvm`.
511-
- Install Node.js with `nvm`: `nvm install 16.15.1`, then use it: `nvm use 16.15.1`. You can list all available Node.js versions with `nvm list available` if you want to pick another version.
511+
- Install Node.js with `nvm`: `nvm install 18.17.0`, then use it: `nvm use 18.17.0`. You can list all available Node.js versions with `nvm list available` if you want to pick another version.
512512
- Install `yarn`: `scoop install yarn`.
513513
- If you need to install `windows-build-tools`, see [`Installing Windows Build Tools`](#installing-windows-build-tools).
514514
- If you run into problems with installing the required build tools, the `node-gyp` documentation offers a useful [guide](https://github.com/nodejs/node-gyp#on-windows) how to install the dependencies manually. The versions required for building Theia are:

doc/runtime-policy.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Version Support Policy
44

5-
We try to support Node.js versions from 12 up to the current _Active LTS_ version.
5+
We aim to support Node.js current _Active LTS_ version.
66

77
See https://nodejs.org/en/about/releases/ to see the status of Node.js versions.
88

@@ -15,6 +15,7 @@ Note that the Node.js version you should use depends on your own project's depen
1515
- Follow Node.js LTS cadence and initiate the update when a new Node.js version becomes _Active LTS_.
1616
- Use `@types/node` for the oldest supported Node version (backward compatibility).
1717
- Update the CI matrix to include the new Node.js versions to support.
18+
- Update the documentation referencing recommended Node versions.
1819
- Update the CHANGELOG.
1920

2021
# Electron

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
"version": "0.0.0",
55
"engines": {
66
"yarn": ">=1.7.0 <2",
7-
"node": ">=16.14.0 <17"
7+
"node": ">=16"
88
},
99
"resolutions": {
10-
"**/@types/node": "16"
10+
"**/@types/node": "18"
1111
},
1212
"devDependencies": {
1313
"@types/chai": "4.3.0",
1414
"@types/chai-spies": "1.0.3",
1515
"@types/chai-string": "^1.4.0",
1616
"@types/jsdom": "^21.1.1",
17-
"@types/node": "16",
17+
"@types/node": "18",
1818
"@types/sinon": "^10.0.6",
1919
"@types/temp": "^0.9.1",
2020
"@types/uuid": "^7.0.3",

packages/core/src/node/backend-application.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
1515
// *****************************************************************************
1616

17+
import * as dns from 'dns';
1718
import * as path from 'path';
1819
import * as http from 'http';
1920
import * as https from 'https';
@@ -29,13 +30,16 @@ import { AddressInfo } from 'net';
2930
import { ApplicationPackage } from '@theia/application-package';
3031
import { ProcessUtils } from './process-utils';
3132

33+
export type DnsResultOrder = 'ipv4first' | 'verbatim' | 'nodeDefault';
34+
3235
const APP_PROJECT_PATH = 'app-project-path';
3336

3437
const TIMER_WARNING_THRESHOLD = 50;
3538

3639
const DEFAULT_PORT = environment.electron.is() ? 0 : 3000;
3740
const DEFAULT_HOST = 'localhost';
3841
const DEFAULT_SSL = false;
42+
const DEFAULT_DNS_DEFAULT_RESULT_ORDER: DnsResultOrder = 'ipv4first';
3943

4044
export const BackendApplicationServer = Symbol('BackendApplicationServer');
4145
/**
@@ -107,6 +111,7 @@ export class BackendApplicationCliContribution implements CliContribution {
107111

108112
port: number;
109113
hostname: string | undefined;
114+
dnsDefaultResultOrder: DnsResultOrder = DEFAULT_DNS_DEFAULT_RESULT_ORDER;
110115
ssl: boolean | undefined;
111116
cert: string | undefined;
112117
certkey: string | undefined;
@@ -119,6 +124,12 @@ export class BackendApplicationCliContribution implements CliContribution {
119124
conf.option('cert', { description: 'Path to SSL certificate.', type: 'string' });
120125
conf.option('certkey', { description: 'Path to SSL certificate key.', type: 'string' });
121126
conf.option(APP_PROJECT_PATH, { description: 'Sets the application project directory', default: this.appProjectPath() });
127+
conf.option('dnsDefaultResultOrder', {
128+
type: 'string',
129+
description: 'Configure Node\'s DNS resolver default behavior, see https://nodejs.org/docs/latest-v18.x/api/dns.html#dnssetdefaultresultorderorder',
130+
choices: ['ipv4first', 'verbatim', 'nodeDefault'],
131+
default: DEFAULT_DNS_DEFAULT_RESULT_ORDER
132+
});
122133
}
123134

124135
setArguments(args: yargs.Arguments): void {
@@ -128,6 +139,7 @@ export class BackendApplicationCliContribution implements CliContribution {
128139
this.cert = args.cert as string;
129140
this.certkey = args.certkey as string;
130141
this.projectPath = args[APP_PROJECT_PATH] as string;
142+
this.dnsDefaultResultOrder = args.dnsDefaultResultOrder as DnsResultOrder;
131143
}
132144

133145
protected appProjectPath(): string {
@@ -234,9 +246,13 @@ export class BackendApplication {
234246
this.app.use(...handlers);
235247
}
236248

237-
async start(aPort?: number, aHostname?: string): Promise<http.Server | https.Server> {
238-
const hostname = aHostname !== undefined ? aHostname : this.cliParams.hostname;
239-
const port = aPort !== undefined ? aPort : this.cliParams.port;
249+
async start(port?: number, hostname?: string): Promise<http.Server | https.Server> {
250+
hostname ??= this.cliParams.hostname;
251+
port ??= this.cliParams.port;
252+
253+
if (this.cliParams.dnsDefaultResultOrder !== 'nodeDefault') {
254+
dns.setDefaultResultOrder(this.cliParams.dnsDefaultResultOrder);
255+
}
240256

241257
const deferred = new Deferred<http.Server | https.Server>();
242258
let server: http.Server | https.Server;
@@ -279,8 +295,10 @@ export class BackendApplication {
279295
});
280296

281297
server.listen(port, hostname, () => {
282-
const scheme = this.cliParams.ssl ? 'https' : 'http';
283-
console.info(`Theia app listening on ${scheme}://${hostname || 'localhost'}:${(server.address() as AddressInfo).port}.`);
298+
// address should be defined at this point
299+
const address = server.address()!;
300+
const url = typeof address === 'string' ? address : this.getHttpUrl(address, this.cliParams.ssl);
301+
console.info(`Theia app listening on ${url}.`);
284302
deferred.resolve(server);
285303
});
286304

@@ -301,6 +319,13 @@ export class BackendApplication {
301319
return this.stopwatch.startAsync('server', 'Finished starting backend application', () => deferred.promise);
302320
}
303321

322+
protected getHttpUrl({ address, port, family }: AddressInfo, ssl?: boolean): string {
323+
const scheme = ssl ? 'https' : 'http';
324+
return family.toLowerCase() === 'ipv6'
325+
? `${scheme}://[${address}]:${port}`
326+
: `${scheme}://${address}:${port}`;
327+
}
328+
304329
protected onStop(): void {
305330
console.info('>>> Stopping backend contributions...');
306331
for (const contrib of this.contributionsProvider.getContributions()) {

packages/core/src/node/logger-cli-contribution.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ describe('log-level-cli-contribution', () => {
137137

138138
const args: yargs.Arguments = yargs.parse(['--log-config', file.path]);
139139
await cli.setArguments(args);
140-
sinon.assert.calledWithMatch(consoleErrorSpy, 'Unexpected token { in JSON at position 1');
140+
sinon.assert.calledWithMatch(consoleErrorSpy, 'Error reading log config file');
141141
});
142142

143143
// Skip this test because it is flaky, sometimes we don't receive the event.

packages/core/src/node/main.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ process.on('unhandledRejection', (reason, promise) => {
2626
throw reason;
2727
});
2828

29-
export interface Address {
30-
readonly port: number;
31-
readonly address: string;
32-
}
33-
34-
export async function start(serverModule: MaybePromise<http.Server | https.Server>): Promise<Address> {
29+
export async function start(serverModule: MaybePromise<http.Server | https.Server>): Promise<AddressInfo> {
3530
const server = await serverModule;
3631
return server.address() as AddressInfo;
3732
}

packages/plugin-ext/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"is-electron": "^2.2.0",
4040
"jsonc-parser": "^2.2.0",
4141
"lodash.clonedeep": "^4.5.0",
42-
"macaddress": "^0.2.9",
42+
"macaddress": "^0.5.3",
4343
"mime": "^2.4.4",
4444
"ps-tree": "^1.2.0",
4545
"semver": "^7.5.4",

0 commit comments

Comments
 (0)