Open
Description
MDN URL: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
What information was incorrect, unhelpful, or incomplete?
The nodejs example of the native app processing messages from FF.
The current example flushes all data ("chunks.splice(0);") after one message has been read - even if there are left-over data/messages in the buffer array.
Specific section or headline?
"App side"
What did you expect to see?
A quick fix would be to push leftover data in the buffer array after buffer flushing, and then process Data again:
// Record leftover data to add back in Chunks
let leftoverData = stringData.slice((payloadSize + 4)); // Note: flushChunksQueue() zeroes payloadSize
// Reset the read size and the queued chunks
flushChunksQueue();
// Add leftover data back in Buffer and repeat processing
if(leftoverData.length){
chunks.push(leftoverData);
processData();
}
Did you test this? If so, how?
Yes. Run my extension and saw that the issue of disappearing/unprocessed messages has gone away.
MDN Content page report details
- Folder:
en-us/mozilla/add-ons/webextensions/native_messaging
- MDN URL: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging
- GitHub URL: https://github.com/mdn/content/blob/master/files/en-us/mozilla/add-ons/webextensions/native_messaging/index.html
- Last commit: 3e5d894
- Document last modified: 2021-02-01T10:33:54.000Z
Metadata
Assignees
Labels
Type
Projects
Status
No status