Skip to content

Commit 706bc87

Browse files
committed
chore: update dependencies and improve error handling
- Moved "@yume-chan/stream-extra" from devDependencies to dependencies - Enhanced WebSocket error handling with logging - Log errors during stream close in WebSocketConnection - Removed unneccesary AGENT_SHA1 empty check
1 parent 97e817e commit 706bc87

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

mbf-site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@vitejs/plugin-react": "^4.2.1",
1818
"@yume-chan/adb-credential-web": "^0.0.24",
1919
"@yume-chan/adb-daemon-webusb": "^0.0.24",
20+
"@yume-chan/stream-extra": "^0.0.24",
2021
"react": "^18.2.0",
2122
"react-dom": "^18.2.0",
2223
"react-spinners": "^0.14.1",
@@ -54,7 +55,6 @@
5455
]
5556
},
5657
"devDependencies": {
57-
"@yume-chan/stream-extra": "^0.0.24",
5858
"concurrently": "^8.2.2"
5959
},
6060
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"

mbf-site/src/AdbServerWebSocketConnector.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,17 @@ class WebSocketConnection {
105105
}
106106
};
107107
// Report errors to the stream controller.
108-
this.socket.onerror = () => controller.error(new Error("WebSocket error"));
108+
this.socket.onerror = (ev) => {
109+
controller.error(new Error("WebSocket error"));
110+
console.error("WebSocket error", ev);
111+
};
109112
// Close the stream when the socket closes.
110113
this.socket.onclose = (event) => {
111114
try {
112115
controller.close();
113-
} catch {
114-
// Ignore errors during stream close.
116+
} catch (error) {
117+
// Ignore errors during stream close, but logs them.
118+
console.error(error);
115119
}
116120
this.closeDeferred.resolve({
117121
closeCode: event.code,
@@ -129,8 +133,9 @@ class WebSocketConnection {
129133
};
130134

131135
// If an error occurs before the socket opens, reject the openDeferred.
132-
this.socket.onerror = () => {
136+
this.socket.onerror = (ev) => {
133137
if (!hasOpened) {
138+
console.error("WebSocket conenction error", ev);
134139
this.openDeferred.reject(new Error("WebSocket connection error"));
135140
}
136141
};

mbf-site/src/Agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function prepareAgent(adb: Adb) {
2828
.trim()
2929
.toUpperCase();
3030
Log.debug("Existing agent SHA1: " + existingSha1);
31-
const existingUpToDate = AGENT_SHA1 && AGENT_SHA1 == existingSha1.trim().toUpperCase();
31+
const existingUpToDate = AGENT_SHA1 == existingSha1.trim().toUpperCase();
3232
if(existingUpToDate) {
3333
Log.info("Agent is up to date");
3434
} else {

0 commit comments

Comments
 (0)