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 for incomplete incoming messages from TP (w/out final newline). #40

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

mpaperno
Copy link
Collaborator

@mpaperno mpaperno commented Nov 7, 2023

This Fixes errors/crashes with messages, or sets of messages, that are too large to fit into one socket buffer before data handler is called, resulting in no terminating newline.

For example when sending long action data (eg. base64 image) or in other cases where socket data builds up, eg. when plugin takes a long time to process a message or is paused in a debugger. I've personally observed all 3 scenarios.

Also as a final check this puts a try/catch around the JSON parsing bit, which at least helps track down anything else unexpected that may happen (not that I've seen that).

Also turns out the data parameter of the on(data) handler was already a string. :) I kept it as a string since apparently it's significantly faster to extract parts of strings than Node Buffers. To make up for the possible buffering overhead, at least we get rid of an array allocation.

-Max

…rsing, otherwise buffer the data and wait for more; Also place a try/catch around `JSON.parse(line)`.

Fixes errors/crashes with messages that are too large for the socket buffer, like when sending long action data (eg. base64 image) or in other cases where socket data builds up, eg. when plugin takes a long time to process a message or is paused in a debugger.
@mpaperno mpaperno requested a review from spdermn02 November 7, 2023 00:04
@mpaperno mpaperno merged commit bb96907 into master Nov 7, 2023
@mpaperno mpaperno deleted the mp/fix_partial_msg_data branch November 7, 2023 01:01
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.

2 participants