Skip to content

Add error handling for debug sockets #2995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/device-sockets/ios/socket-proxy-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
webSocket.send(buffer.toString(encoding));
});

webSocket.on("error", err => {
this.$logger.trace("Error on debugger websocket", err);
});

deviceSocket.on("error", err => {
this.$logger.trace("Error on debugger deviceSocket", err);
});

webSocket.on("message", (message, flags) => {
let length = Buffer.byteLength(message, encoding);
let payload = new Buffer(length + 4);
Expand All @@ -121,9 +129,11 @@ export class SocketProxyFactory extends EventEmitter implements ISocketProxyFact
deviceSocket.write(payload);
});

deviceSocket.on("end", () => {
deviceSocket.on("close", () => {
this.$logger.info("Backend socket closed!");
process.exit(0);
if (!this.$options.watch) {
process.exit(0);
}
});

webSocket.on("close", () => {
Expand Down