fix(core): handle multiple messages (#17199)

This commit is contained in:
William Sedlacek 2023-05-24 15:26:09 -07:00 committed by GitHub
parent c9ec7d0f04
commit c57f7b825d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,13 @@ export function consumeMessagesFromSocket(callback: (message: string) => void) {
const chunk = data.toString();
if (chunk.codePointAt(chunk.length - 1) === 4) {
message += chunk.substring(0, chunk.length - 1);
callback(message);
// Server may send multiple messages in one chunk, so splitting by 0x4
const messages = message.split('');
for (const splitMessage of messages) {
callback(splitMessage);
}
message = '';
} else {
message += chunk;