mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-13 12:19:29 +00:00
Reconnect on interrupted system call.
However, we have to figure out why does it happen at all. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
@@ -109,13 +109,14 @@ export class BoardsServiceImpl implements BoardsService {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.logger.info('>>> Disposing boards service...')
|
||||
this.logger.info('>>> Disposing boards service...');
|
||||
this.queue.pause();
|
||||
this.queue.clear();
|
||||
if (this.discoveryTimer !== undefined) {
|
||||
clearInterval(this.discoveryTimer);
|
||||
}
|
||||
this.logger.info('<<< Disposed boards service.')
|
||||
this.logger.info('<<< Disposed boards service.');
|
||||
this.client = undefined;
|
||||
}
|
||||
|
||||
async getAttachedBoards(): Promise<{ boards: Board[] }> {
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace ErrorWithCode {
|
||||
return {
|
||||
connectionId,
|
||||
message,
|
||||
// message: `Cancelled on client. ${Board.toString(board)} from port ${Port.toString(port)}.`,
|
||||
code: MonitorError.ErrorCodes.CLIENT_CANCEL,
|
||||
config
|
||||
};
|
||||
@@ -40,7 +39,6 @@ namespace ErrorWithCode {
|
||||
case 'device not configured': {
|
||||
return {
|
||||
connectionId,
|
||||
// message: ``,
|
||||
message,
|
||||
code: MonitorError.ErrorCodes.DEVICE_NOT_CONFIGURED,
|
||||
config
|
||||
@@ -49,12 +47,19 @@ namespace ErrorWithCode {
|
||||
case 'error opening serial monitor: Serial port busy': {
|
||||
return {
|
||||
connectionId,
|
||||
// message: `Connection failed. Serial port is busy: ${Port.toString(port)}.`,
|
||||
message,
|
||||
code: MonitorError.ErrorCodes.DEVICE_BUSY,
|
||||
config
|
||||
}
|
||||
}
|
||||
case 'interrupted system call': {
|
||||
return {
|
||||
connectionId,
|
||||
message,
|
||||
code: MonitorError.ErrorCodes.interrupted_system_call,
|
||||
config
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.warn(`Unhandled error with code:`, error);
|
||||
@@ -81,9 +86,12 @@ export class MonitorServiceImpl implements MonitorService {
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.logger.info('>>> Disposing monitor service...');
|
||||
for (const [connectionId, duplex] of this.connections.entries()) {
|
||||
this.doDisconnect(connectionId, duplex);
|
||||
}
|
||||
this.logger.info('<<< Disposing monitor service...');
|
||||
this.client = undefined;
|
||||
}
|
||||
|
||||
async connect(config: MonitorConfig): Promise<{ connectionId: string }> {
|
||||
@@ -96,12 +104,6 @@ export class MonitorServiceImpl implements MonitorService {
|
||||
);
|
||||
|
||||
duplex.on('error', ((error: Error) => {
|
||||
// Dispose the connection on error.
|
||||
// If the client has disconnected, we call `disconnect` and hit this error
|
||||
// no need to disconnect once more.
|
||||
if (!toDispose.disposed) {
|
||||
toDispose.dispose();
|
||||
}
|
||||
if (ErrorWithCode.is(error)) {
|
||||
const monitorError = ErrorWithCode.toMonitorError(error, connectionId, config);
|
||||
if (monitorError) {
|
||||
@@ -109,9 +111,22 @@ export class MonitorServiceImpl implements MonitorService {
|
||||
this.client.notifyError(monitorError);
|
||||
}
|
||||
// Do not log the error, it was expected. The client will take care of the rest.
|
||||
if (monitorError.code === MonitorError.ErrorCodes.interrupted_system_call) {
|
||||
console.log('jajjajaja');
|
||||
if (!toDispose.disposed) {
|
||||
toDispose.dispose();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (error.message === 'interrupted system call') {
|
||||
this.logger.info('TODO: reduce to debug, INTERRUPTED SYSTEM CALL');
|
||||
return; // Continue.
|
||||
}
|
||||
if (!toDispose.disposed) {
|
||||
toDispose.dispose();
|
||||
}
|
||||
this.logger.error(`Error occurred for connection ${connectionId}.`, error);
|
||||
}).bind(this));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user