Skip to content

Commit 19acf2e

Browse files
fix: Chrome debug messages from iOS Runtime are not parsed correctly
During debug operation, iOS Runtime "talks" to Chrome DevTools. CLI stands as proxy between them and translates the messages. Due to Node.js socket implementation, some messages may come on chunks. The format of each message is: - first 4 bytes contain the lenght of the message (in Big-Endian) - the next bytes are the actual message Currently, the following behavior is observed: - when a full message is received, CLI sends it correctly to Chrome DevTools - when more than one message is received in the data, CLI sends only the first message to Chrome DevTools and disregards the other part - in case a split message is received, when the first part is only part of the first 4 bytes (part of the length), CLI fails with `Index out of Range` or `ERR_BUFFER_OUT_OF_BOUNDS` error (based on the inner state of the variables). To fix this behavior, remove CLI's parsing and reuse the one from `ios-device-lib`.
1 parent 6bb7f8b commit 19acf2e

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

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

Lines changed: 2 additions & 2 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,7 +134,7 @@ 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) => {

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

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

0 commit comments

Comments
 (0)