Skip to content

Commit d50f2e4

Browse files
Merge pull request #4286 from NativeScript/vladimirov/fix-index-out-of-range-debug
fix: errors during debug on iOS
2 parents 2df6ae6 + 19acf2e commit d50f2e4

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

lib/device-sockets/ios/app-debug-socket-proxy-factory.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { EventEmitter } from "events";
22
import { CONNECTION_ERROR_EVENT_NAME } from "../../constants";
3-
import { PacketStream } from "./packet-stream";
43
import * as net from "net";
54
import * as ws from "ws";
65
import temp = require("temp");
6+
import { MessageUnpackStream } from "ios-device-lib";
77

88
export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebugSocketProxyFactory {
99
private deviceWebServers: IDictionary<ws.Server> = {};
@@ -134,11 +134,16 @@ export class AppDebugSocketProxyFactory extends EventEmitter implements IAppDebu
134134
const encoding = "utf16le";
135135

136136
const appDebugSocket: net.Socket = (<any>req)["__deviceSocket"];
137-
const packets = new PacketStream();
137+
const packets = new MessageUnpackStream();
138138
appDebugSocket.pipe(packets);
139139

140140
packets.on("data", (buffer: Buffer) => {
141-
webSocket.send(buffer.toString(encoding));
141+
const message = buffer.toString(encoding);
142+
if (webSocket.readyState === webSocket.OPEN) {
143+
webSocket.send(message);
144+
} else {
145+
this.$logger.trace(`Received message ${message}, but unable to send it to webSocket as its state is: ${webSocket.readyState}`);
146+
}
142147
});
143148

144149
webSocket.on("error", err => {

lib/device-sockets/ios/packet-stream.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

npm-shrinkwrap.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"gaze": "1.1.0",
4646
"iconv-lite": "0.4.11",
4747
"inquirer": "6.2.0",
48-
"ios-device-lib": "0.4.15",
48+
"ios-device-lib": "0.5.0",
4949
"ios-mobileprovision-finder": "1.0.10",
5050
"ios-sim-portable": "4.0.6",
5151
"istextorbinary": "2.2.1",

0 commit comments

Comments
 (0)