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(GUI): multiple JSON objects coming up at once from the IPC client #997

Merged
merged 1 commit into from Jan 5, 2017

Conversation

jviotti
Copy link
Contributor

@jviotti jviotti commented Jan 4, 2017

The GUI executes the CLI and pipes every line of output coming from
either stdout or stderr to the IPC server as "messages."

In some scenarios, the child process data handler might receive multiple
lines of output at the same time. Since the CLI outputs stringified JSON
objects each in a different line, trying to parse two JSON objects
separated by a new line causes the parser to crash.

As a solution, we split the data coming in by new lines (\r\n in
Windows), and emit a message for only the last one.

Fixes: #898
Changelog-Entry: Fix "Invalid message" error caused by the IPC client emitting multiple JSON objects as a single message.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti jviotti@openmailbox.org

@jviotti jviotti force-pushed the fix-multiple-json-ipc branch 2 times, most recently from 101e8ac to c5c672c Compare January 5, 2017 16:29
The GUI executes the CLI and pipes every line of output coming from
either `stdout` or `stderr` to the IPC server as "messages."

In some scenarios, the child process data handler might receive multiple
lines of output at the same time. Since the CLI outputs stringified JSON
objects each in a different line, trying to parse two JSON objects
separated by a new line causes the parser to crash.

As a solution, we split the data coming in by new lines (`\r\n` in
Windows), and emit a message for only the last one.

Fixes: #898
Changelog-Entry: Fix "Invalid message" error caused by the IPC client emitting multiple JSON objects as a single message.
Change-Type: patch
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
@jviotti jviotti merged commit 405b98d into master Jan 5, 2017
@jviotti jviotti deleted the fix-multiple-json-ipc branch January 5, 2017 17:59
jviotti pushed a commit that referenced this pull request Jan 9, 2017
We've recently PRed a commit that handles multiple IPC messages being
triggered at the same time, confusing `JSON.parse()`. As a solution to
such problem, we are splitting the CLI output on new lines, based on the
assumption that each line represents a different object, however we
didn't consider that in the case of errors, we include an `stacktrace`
property which usually includes new line characters, causing such
information to be completely garbled and cause `JSON.parse()` once again
to get confused.

As a solution, we only split by new lines that are not surrounded by
quotes (since they represent a JSON property).

See: #997
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
jviotti pushed a commit that referenced this pull request Jan 9, 2017
We've recently PRed a commit that handles multiple IPC messages being
triggered at the same time, confusing `JSON.parse()`. As a solution to
such problem, we are splitting the CLI output on new lines, based on the
assumption that each line represents a different object, however we
didn't consider that in the case of errors, we include an `stacktrace`
property which usually includes new line characters, causing such
information to be completely garbled and cause `JSON.parse()` once again
to get confused.

As a solution, we only split by new lines that are not surrounded by
quotes (since they represent a JSON property).

See: #997
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
jviotti pushed a commit that referenced this pull request Jan 10, 2017
We've recently PRed a commit that handles multiple IPC messages being
triggered at the same time, confusing `JSON.parse()`. As a solution to
such problem, we are splitting the CLI output on new lines, based on the
assumption that each line represents a different object, however we
didn't consider that in the case of errors, we include an `stacktrace`
property which usually includes new line characters, causing such
information to be completely garbled and cause `JSON.parse()` once again
to get confused.

As a solution, we only split by new lines that are not surrounded by
quotes (since they represent a JSON property).

See: #997
Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant