Skip to content
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

fix: errors during debug on iOS #4286

Merged
merged 3 commits into from
Jan 15, 2019

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Jan 15, 2019

fix: error is raised when DevTools are closed while sending message

In case you open Chrome DevTools and close them while the iOS runtime still sends messages, an error is raised in CLI:

Error: WebSocket is not open: readyState 2 (CLOSING)

The problem is that we are using Transform stream between the communication and close event of the socket is not raised until the stream flushes its current state.
Fix it by skipping the write operation in case the socket is not in OPEN state.

chore: update ios-device-lib to 0.5.0

Update ios-device-lib to 0.5.0, so we can use the new fixes and features: https://github.com/telerik/ios-device-lib/releases/tag/v0.5.0
6bb7f8b

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.

PR Checklist

Related to issues:

In case you open Chrome DevTools and close them while the iOS runtime still sends messages, an error is raised in CLI:
```
Error: WebSocket is not open: readyState 2 (CLOSING)
```

The problem is that we are using Transform stream between the communication and close event of the socket is not raised until the stream flushes its current state.
Fix it by skipping the write operation in case the socket is not in OPEN state.
Update ios-device-lib to 0.5.0, so we can use the new fixes and features: https://github.com/telerik/ios-device-lib/releases/tag/v0.5.0
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`.
Copy link
Contributor

@DimitarTachev DimitarTachev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇 🥇 🥇

@rosen-vladimirov rosen-vladimirov merged commit d50f2e4 into release Jan 15, 2019
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-index-out-of-range-debug branch January 15, 2019 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants