Skip to content

Commit 1b4b1df

Browse files
committed
Fixed broken promise in loadPropeller() and delayed closePort()'s resolve by 250 ms to prevent future openPort() calls from arriving too soon for the OS to accommodate.
1 parent ec05a83 commit 1b4b1df

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function loadPropeller(sock, portPath, action, payload, debug) {
142142
if (port.connId) {
143143
// Connection exists, prep to close it first (to reset it), then open it (fresh)
144144
originalBaudrate = initialBaudrate;
145-
connect = function() {closePort(port).then(function() {return openPort(sock, portPath, initialBaudrate, "programming")}).catch(function(e) {return Promise.reject(e)})}
145+
connect = function() {return closePort(port).then(function() {return openPort(sock, portPath, initialBaudrate, "programming")}).catch(function(e) {return Promise.reject(e)})}
146146
// The following temporarily removed (and replaced above) to intentionally close and reopen port in hopes it eliminates the CrOS v67+ failed download problem
147147
// // Connection exists, prep to reuse it
148148
// originalBaudrate = port.baud;

serial.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function closePort(port, command) {
140140
log("Closed port " + port.path + " (id " + port.connId + ")", mDbug);
141141
// Clear connection id to indicate port is closed
142142
updatePort(port, {connId: null});
143-
resolve();
143+
setTimeout(resolve, 250); //Delay resolve() to prevent future openPort() calls from arriving too soon to accommodate
144144
} else {
145145
log("Could not close port " + port.path + " (id " + port.connId + ")", mDbug);
146146
reject(Error(notice(neCanNotClosePort, [port.path])));

0 commit comments

Comments
 (0)