Skip to content

Commit

Permalink
fix CheckRunTimeError (#3284)
Browse files Browse the repository at this point in the history
fic CheckRunTimeError
  • Loading branch information
haslinghuis authored Jan 27, 2023
1 parent acd92a4 commit 697943b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/js/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const serial = {
self.connectionType = 'serial';

chrome.serial.connect(path, options, function (connectionInfo) {
if (connectionInfo && !self.openCanceled && !checkChromeRuntimeError()) {
self.failed = checkChromeRuntimeError();
if (connectionInfo && !self.openCanceled && !self.failed) {
self.connected = true;
self.connectionId = connectionInfo.connectionId;
self.bitrate = connectionInfo.bitrate;
Expand All @@ -65,6 +66,7 @@ const serial = {
if (!self.failed++) {
chrome.serial.setPaused(self.connectionId, false, function () {
self.getInfo(function (getInfo) {
checkChromeRuntimeError();
if (getInfo) {
if (!getInfo.paused) {
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
Expand All @@ -74,8 +76,6 @@ const serial = {
gui_log(i18n.getMessage('serialUnrecoverable'));
self.errorHandler(getInfo.error, 'receive');
}
} else {
checkChromeRuntimeError();
}
});
});
Expand All @@ -87,13 +87,14 @@ const serial = {
self.error = info.error;
setTimeout(function() {
chrome.serial.setPaused(info.connectionId, false, function() {
self.getInfo(function (_info) {
if (_info) {
if (_info.paused) {
checkChromeRuntimeError();
self.getInfo(function (getInfo) {
if (getInfo) {
if (getInfo.paused) {
// assume unrecoverable, disconnect
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
gui_log(i18n.getMessage('serialUnrecoverable'));
self.errorHandler(_info.error, 'receive');
self.errorHandler(getInfo.error, 'receive');
}
else {
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);
Expand Down
3 changes: 2 additions & 1 deletion src/js/utils/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import semver from "semver";
import { mixerList } from "../model";
import CONFIGURATOR from "../data_storage";
import { gui_log } from "../gui_log";

export function millitime() {
return new Date().getTime();
Expand Down Expand Up @@ -39,7 +40,7 @@ export function isInt(n) {
export function checkChromeRuntimeError() {
if (chrome.runtime.lastError) {
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);

gui_log(`Chrome API Error: ${chrome.runtime.lastError.message}.`);
return true;
}
return false;
Expand Down

0 comments on commit 697943b

Please sign in to comment.