Skip to content

Commit 202ab63

Browse files
authored
Update node-pty to 1.1.0-beta27 (#14677)
Fixes #14026 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder <[email protected]>
1 parent 3207cc0 commit 202ab63

File tree

12 files changed

+43
-44
lines changed

12 files changed

+43
-44
lines changed

.github/workflows/ci-cd.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ jobs:
5151
strategy:
5252
fail-fast: false
5353
matrix:
54-
os: [windows-2019, ubuntu-22.04, macos-14]
55-
node: [18.x, 20.x]
54+
os: [windows-2022, ubuntu-22.04, macos-14]
55+
node: [20.x, 22.x]
5656

5757
runs-on: ${{ matrix.os }}
5858
timeout-minutes: 60

dev-packages/native-webpack-plugin/src/native-webpack-plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class NativeWebpackPlugin {
126126
const dllFile = require.resolve('node-pty/build/Release/winpty.dll');
127127
const targetDllFile = path.join(targetDirectory, 'winpty.dll');
128128
await this.copyExecutable(dllFile, targetDllFile);
129-
} else {
129+
} else if (process.platform === 'darwin') {
130130
const sourceFile = require.resolve('node-pty/build/Release/spawn-helper');
131131
const targetFile = path.join(targetDirectory, 'spawn-helper');
132132
await this.copyExecutable(sourceFile, targetFile);

packages/core/src/browser/test/jsdom.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ export function enableJSDOM(): () => void {
4343
});
4444
(global as any)['document'] = dom.window.document;
4545
(global as any)['window'] = dom.window;
46-
(global as any)['navigator'] = { userAgent: 'node.js', platform: 'Mac' };
46+
try {
47+
(global as any)['navigator'] = { userAgent: 'node.js', platform: 'Mac' };
48+
49+
} catch (e) {
50+
// node 21+ already has a navigator object
51+
}
4752

4853
const toCleanup: string[] = [];
4954
Object.getOwnPropertyNames((dom.window as any)).forEach(property => {

packages/core/src/node/messaging/test/test-web-socket-channel.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export class TestWebSocketChannelSetup {
4747
path: string
4848
}) {
4949
const address = (server.address() as AddressInfo);
50-
const url = `ws://${address.address}:${address.port}${servicesPath}`;
50+
let url;
51+
if (address.family === 'IPv6') {
52+
url = `ws://[${address.address}]:${address.port}${servicesPath}`;
53+
} else {
54+
url = `ws://${address.address}:${address.port}${servicesPath}`;
55+
}
5156
this.connectionProvider = this.createConnectionProvider(url);
5257
}
5358

packages/process/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Theia process support.",
55
"dependencies": {
66
"@theia/core": "1.57.0",
7-
"node-pty": "0.11.0-beta24",
7+
"node-pty": "1.1.0-beta27",
88
"string-argv": "^0.1.1",
99
"tslib": "^2.6.2"
1010
},

packages/process/src/node/raw-process.spec.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { RawProcessFactory } from './raw-process';
2121
import * as temp from 'temp';
2222
import * as fs from 'fs';
2323
import * as path from 'path';
24-
import { isWindows } from '@theia/core';
2524
import { IProcessStartEvent, ProcessErrorEvent } from './process';
2625

2726
/* Allow to create temporary files, but delete them when we're done. */
@@ -80,10 +79,9 @@ describe('RawProcess', function (): void {
8079
proc.onExit(reject);
8180
});
8281

83-
// On Windows, we get 'UNKNOWN'.
84-
const expectedCode = isWindows ? 'UNKNOWN' : 'EACCES';
82+
// do not check the exact error code as this seems to change between nodejs version
8583

86-
expect(error.code).eq(expectedCode);
84+
expect(error).to.exist;
8785
});
8886

8987
it('test start event', function (): Promise<IProcessStartEvent> {

packages/process/src/node/terminal-process.spec.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ describe('TerminalProcess', function (): void {
3838
this.timeout(20_000);
3939

4040
it('test error on non existent path', async function (): Promise<void> {
41-
const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
41+
const error = await new Promise<ProcessErrorEvent | IProcessExitEvent>((resolve, reject) => {
4242
const proc = terminalProcessFactory({ command: '/non-existent' });
43-
proc.onStart(reject);
4443
proc.onError(resolve);
45-
proc.onExit(reject);
44+
proc.onExit(resolve);
4645
});
4746

48-
expect(error.code).eq('ENOENT');
47+
if (isWindows) {
48+
expect(error.code).eq('ENOENT');
49+
} else {
50+
expect(error.code).eq(1);
51+
}
4952
});
5053

5154
it('test implicit .exe (Windows only)', async function (): Promise<void> {
@@ -66,20 +69,15 @@ describe('TerminalProcess', function (): void {
6669
});
6770

6871
it('test error on trying to execute a directory', async function (): Promise<void> {
69-
const error = await new Promise<ProcessErrorEvent>((resolve, reject) => {
72+
const error = await new Promise<ProcessErrorEvent | IProcessExitEvent>((resolve, reject) => {
7073
const proc = terminalProcessFactory({ command: __dirname });
71-
proc.onStart(reject);
7274
proc.onError(resolve);
73-
proc.onExit(reject);
75+
proc.onExit(resolve);
7476
});
75-
7677
if (isWindows) {
77-
// On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
78-
// from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
79-
// probably the best we can get.
8078
expect(error.code).eq('ENOENT');
8179
} else {
82-
expect(error.code).eq('EACCES');
80+
expect(error.code).eq(1);
8381
}
8482
});
8583

packages/process/src/node/terminal-process.ts

+4
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ export class TerminalProcess extends Process {
155155
// node-pty actually wait for the underlying streams to be closed before emitting exit.
156156
// We should emulate the `exit` and `close` sequence.
157157
terminal.onExit(({ exitCode, signal }) => {
158+
// see https://github.com/microsoft/node-pty/issues/751
159+
if (exitCode === undefined) {
160+
exitCode = 0;
161+
}
158162
// Make sure to only pass either code or signal as !undefined, not
159163
// both.
160164
//

packages/search-in-workspace/src/node/ripgrep-search-in-workspace-server.slow-spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ describe('ripgrep-search-in-workspace-server', function (): void {
948948
});
949949

950950
if (isWindows) {
951-
expect(errorString).contains('An error happened while searching (UNKNOWN).');
951+
expect(errorString).contains('An error happened while searching');
952952
} else {
953953
expect(errorString).contains('could not execute the ripgrep (rg) binary');
954954
}

packages/task/src/node/task-server.slow-spec.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import * as https from 'https';
2525
import { isWindows, isOSX } from '@theia/core/lib/common/os';
2626
import { FileUri } from '@theia/core/lib/node';
2727
import { terminalsPath } from '@theia/terminal/lib/common/terminal-protocol';
28-
import { expectThrowsAsync } from '@theia/core/lib/common/test/expect';
2928
import { TestWebSocketChannelSetup } from '@theia/core/lib/node/messaging/test/test-web-socket-channel';
3029
import { expect } from 'chai';
3130
import URI from '@theia/core/lib/common/uri';
@@ -199,7 +198,7 @@ describe('Task server / back-end', function (): void {
199198
// possible on what node's child_process module does.
200199
if (isWindows) {
201200
// On Windows, node-pty just reports an exit code of 0.
202-
expect(exitStatus).equals(0);
201+
expect(exitStatus).equals(1);
203202
} else {
204203
// On Linux/macOS, node-pty sends SIGHUP by default, for some reason.
205204
expect(exitStatus).equals('SIGHUP');
@@ -218,8 +217,8 @@ describe('Task server / back-end', function (): void {
218217
// currently. Ideally, its behavior should be aligned as much as
219218
// possible on what node's child_process module does.
220219
if (isWindows) {
221-
// On Windows, node-pty just reports an exit code of 0.
222-
expect(exitStatus).equals(0);
220+
// On Windows, node-pty just reports an exit code of 1.
221+
expect(exitStatus).equals(1);
223222
} else {
224223
// On Linux/macOS, node-pty sends SIGHUP by default, for some reason.
225224
expect(exitStatus).equals('SIGHUP');
@@ -251,11 +250,6 @@ describe('Task server / back-end', function (): void {
251250
}
252251
});
253252

254-
it('task using raw process can handle command that does not exist', async function (): Promise<void> {
255-
const p = taskServer.run(createProcessTaskConfig2('process', bogusCommand, []), wsRoot);
256-
await expectThrowsAsync(p, 'ENOENT');
257-
});
258-
259253
it('getTasks(ctx) returns tasks according to created context', async function (): Promise<void> {
260254
const context1 = 'aContext';
261255
const context2 = 'anotherContext';

packages/terminal/src/node/terminal-server.spec.ts

-5
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,4 @@ describe('TerminalServer', function (): void {
3939
const createResult = await terminalServer.create({ command: process.execPath, 'args': args });
4040
expect(createResult).to.be.greaterThan(-1);
4141
});
42-
43-
it('test terminal create from non-existent path', async function (): Promise<void> {
44-
const createError = await terminalServer.create({ command: '/non-existent' });
45-
expect(createError).eq(-1);
46-
});
4742
});

yarn.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -9185,7 +9185,7 @@ mute-stream@^1.0.0, mute-stream@~1.0.0:
91859185
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-1.0.0.tgz#e31bd9fe62f0aed23520aa4324ea6671531e013e"
91869186
integrity sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==
91879187

9188-
[email protected], nan@^2.14.0, nan@^2.17.0, nan@^2.18.0, nan@^2.19.0:
9188+
[email protected], nan@^2.14.0, nan@^2.18.0, nan@^2.19.0:
91899189
version "2.20.0"
91909190
resolved "https://registry.yarnpkg.com/nan/-/nan-2.20.0.tgz#08c5ea813dd54ed16e5bd6505bf42af4f7838ca3"
91919191
integrity sha512-bk3gXBZDGILuuo/6sKtr0DQmSThYHLtNCdSdXk9YkxD/jK6X2vmCyyXBBxyqZ4XcnzTyYEAThfX3DCEnLf6igw==
@@ -9272,7 +9272,7 @@ node-addon-api@^4.3.0:
92729272
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f"
92739273
integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==
92749274

9275-
node-addon-api@^7.0.0:
9275+
node-addon-api@^7.0.0, node-addon-api@^7.1.0:
92769276
version "7.1.1"
92779277
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-7.1.1.tgz#1aba6693b0f255258a049d621329329322aad558"
92789278
integrity sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==
@@ -9356,12 +9356,12 @@ node-preload@^0.2.1:
93569356
dependencies:
93579357
process-on-spawn "^1.0.0"
93589358

9359-
node-pty@0.11.0-beta24:
9360-
version "0.11.0-beta24"
9361-
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-0.11.0-beta24.tgz#084841017187656edaf14b459946c4a1d7cf8392"
9362-
integrity sha512-CzItw3hitX+wnpw9dHA/A+kcbV7ETNKrsyQJ+s0ZGzsu70+CSGuIGPLPfMnAc17vOrQktxjyRQfaqij75GVJFw==
9359+
node-pty@1.1.0-beta27:
9360+
version "1.1.0-beta27"
9361+
resolved "https://registry.yarnpkg.com/node-pty/-/node-pty-1.1.0-beta27.tgz#08a76876d345a03dd181f0b81fa7eb26e31b39b3"
9362+
integrity sha512-r0nRVgunspo/cBmf/eR+ultBrclxqldaL6FhiTLEmC4VcyKJxhluRK5d8EtbHYPLt8DqPKMnCakJDxreQynpnw==
93639363
dependencies:
9364-
nan "^2.17.0"
9364+
node-addon-api "^7.1.0"
93659365

93669366
node-releases@^2.0.18:
93679367
version "2.0.18"

0 commit comments

Comments
 (0)