Skip to content

Commit 30136b0

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Capture and swallow unhandled SIGPIPE signal.
To be able to work around the backend process crash and offline status. Ref: eclipse-theia/theia#8660 Signed-off-by: Akos Kitta <[email protected]>
1 parent 53b06ae commit 30136b0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Diff for: arduino-ide-extension/src/node/arduino-ide-backend-module.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { join } from 'path';
44
import { ContainerModule } from 'inversify';
55
import { ArduinoDaemonImpl } from './arduino-daemon-impl';
66
import { ILogger } from '@theia/core/lib/common/logger';
7-
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
7+
import { BackendApplicationContribution, BackendApplication as TheiaBackendApplication } from '@theia/core/lib/node/backend-application';
88
import { LibraryService, LibraryServicePath } from '../common/protocol/library-service';
99
import { BoardsService, BoardsServicePath } from '../common/protocol/boards-service';
1010
import { LibraryServiceImpl } from './library-service-server-impl';
@@ -38,8 +38,12 @@ import { ExecutableServiceImpl } from './executable-service-impl';
3838
import { OutputServicePath, OutputService } from '../common/protocol/output-service';
3939
import { NotificationServiceServerImpl } from './notification-service-server';
4040
import { NotificationServiceServer, NotificationServiceClient, NotificationServicePath } from '../common/protocol';
41+
import { BackendApplication } from './theia/core/backend-application';
4142

4243
export default new ContainerModule((bind, unbind, isBound, rebind) => {
44+
bind(BackendApplication).toSelf().inSingletonScope();
45+
rebind(TheiaBackendApplication).toService(BackendApplication);
46+
4347
// Shared config service
4448
bind(ConfigFileValidator).toSelf().inSingletonScope();
4549
bind(ConfigServiceImpl).toSelf().inSingletonScope();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { inject, injectable, named } from 'inversify';
2+
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
3+
import { BackendApplication as TheiaBackendApplication, BackendApplicationContribution, BackendApplicationCliContribution } from '@theia/core/lib/node/backend-application';
4+
5+
@injectable()
6+
export class BackendApplication extends TheiaBackendApplication {
7+
8+
constructor(
9+
@inject(ContributionProvider) @named(BackendApplicationContribution) protected readonly contributionsProvider: ContributionProvider<BackendApplicationContribution>,
10+
@inject(BackendApplicationCliContribution) protected readonly cliParams: BackendApplicationCliContribution
11+
) {
12+
super(contributionsProvider, cliParams);
13+
// Workaround for Electron not installing a handler to ignore SIGPIPE
14+
// (https://github.com/electron/electron/issues/13254)
15+
// From VS Code: https://github.com/microsoft/vscode/blob/d0c90c9f3ea8d34912194176241503a44b3abd80/src/bootstrap.js#L31-L37
16+
process.on('SIGPIPE', () => console.error(new Error('Unexpected SIGPIPE signal.')));
17+
}
18+
19+
}

0 commit comments

Comments
 (0)