Skip to content

Commit d8a742e

Browse files
author
Akos Kitta
committed
GH-240: Warn if not connected to the Internet.
Make sure the gRPC client initialization is rejected. Closes #240. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent f1fca4d commit d8a742e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ export class ArduinoFrontendContribution implements FrontendApplicationContribut
157157

158158
@postConstruct()
159159
protected async init(): Promise<void> {
160+
if (!window.navigator.onLine) {
161+
// tslint:disable-next-line:max-line-length
162+
this.messageService.warn('You appear to be offline. Without an Internet connection, the Arduino CLI might not be able to download the required resources and could cause malfunction. Please connect to the Internet and restart the application.');
163+
}
160164
const updateStatusBar = (config: BoardsConfig.Config) => {
161165
this.statusBar.setElement('arduino-selected-board', {
162166
alignment: StatusBarAlignment.RIGHT,

arduino-ide-extension/src/node/core-client-provider.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
3838
const client = new ArduinoCoreClient(`localhost:${port}`, grpc.credentials.createInsecure(), this.channelOptions);
3939
const initReq = new InitReq();
4040
initReq.setLibraryManagerOnly(false);
41-
const initResp = await new Promise<InitResp>(resolve => {
41+
const initResp = await new Promise<InitResp>((resolve, reject) => {
4242
let resp: InitResp | undefined = undefined;
4343
const stream = client.init(initReq);
4444
stream.on('data', (data: InitResp) => resp = data);
4545
stream.on('end', () => resolve(resp));
46-
stream.on('error', err => {
47-
console.log('init error', err)
48-
});
46+
stream.on('error', err => reject(err));
4947
});
5048

5149
const instance = initResp.getInstance();

0 commit comments

Comments
 (0)