Skip to content

Issue with "Native messaging": current example flushes all data after one message has been read - even if there are left-over data/messages in the buffer array. #2059

Open
@aliko-str

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

Metadata

Assignees

Labels

Content:WebExtWebExtensions docshelp wantedIf you know something about this topic, we would love your help!p2Minor issue with low priority, can be fixed later.

Type

No type

Projects

  • Status

    No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions