Skip to content

Commit f578c36

Browse files
committed
Ensure we correctly release the lock on the writer (in the promise) - allows us to disconnect from Web Serial correctly on Linux without hogging the port
1 parent b9c0f37 commit f578c36

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/serial_web_serial.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,13 @@
160160
function writeSerial(data, callback) {
161161
var writer = serialPort.writable.getWriter();
162162
writer.write(Espruino.Core.Utils.stringToArrayBuffer(data)).then(function() {
163+
writer.releaseLock();
163164
callback();
164165
}).catch(function(error) {
166+
writer.releaseLock();
165167
console.log('Serial> SEND ERROR: ' + error);
166168
closeSerial();
167-
});
168-
writer.releaseLock();
169+
});
169170
}
170171

171172
// ----------------------------------------------------------

0 commit comments

Comments
 (0)