Skip to content

Commit 697943b

Browse files
authored
fix CheckRunTimeError (#3284)
fic CheckRunTimeError
1 parent acd92a4 commit 697943b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/js/serial.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const serial = {
4747
self.connectionType = 'serial';
4848

4949
chrome.serial.connect(path, options, function (connectionInfo) {
50-
if (connectionInfo && !self.openCanceled && !checkChromeRuntimeError()) {
50+
self.failed = checkChromeRuntimeError();
51+
if (connectionInfo && !self.openCanceled && !self.failed) {
5152
self.connected = true;
5253
self.connectionId = connectionInfo.connectionId;
5354
self.bitrate = connectionInfo.bitrate;
@@ -65,6 +66,7 @@ const serial = {
6566
if (!self.failed++) {
6667
chrome.serial.setPaused(self.connectionId, false, function () {
6768
self.getInfo(function (getInfo) {
69+
checkChromeRuntimeError();
6870
if (getInfo) {
6971
if (!getInfo.paused) {
7072
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
@@ -74,8 +76,6 @@ const serial = {
7476
gui_log(i18n.getMessage('serialUnrecoverable'));
7577
self.errorHandler(getInfo.error, 'receive');
7678
}
77-
} else {
78-
checkChromeRuntimeError();
7979
}
8080
});
8181
});
@@ -87,13 +87,14 @@ const serial = {
8787
self.error = info.error;
8888
setTimeout(function() {
8989
chrome.serial.setPaused(info.connectionId, false, function() {
90-
self.getInfo(function (_info) {
91-
if (_info) {
92-
if (_info.paused) {
90+
checkChromeRuntimeError();
91+
self.getInfo(function (getInfo) {
92+
if (getInfo) {
93+
if (getInfo.paused) {
9394
// assume unrecoverable, disconnect
9495
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
9596
gui_log(i18n.getMessage('serialUnrecoverable'));
96-
self.errorHandler(_info.error, 'receive');
97+
self.errorHandler(getInfo.error, 'receive');
9798
}
9899
else {
99100
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);

src/js/utils/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import semver from "semver";
22
import { mixerList } from "../model";
33
import CONFIGURATOR from "../data_storage";
4+
import { gui_log } from "../gui_log";
45

56
export function millitime() {
67
return new Date().getTime();
@@ -39,7 +40,7 @@ export function isInt(n) {
3940
export function checkChromeRuntimeError() {
4041
if (chrome.runtime.lastError) {
4142
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);
42-
43+
gui_log(`Chrome API Error: ${chrome.runtime.lastError.message}.`);
4344
return true;
4445
}
4546
return false;

0 commit comments

Comments
 (0)