-
Notifications
You must be signed in to change notification settings - Fork 22.7k
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
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
Comments
I can update this 👍 |
Take it away, Alexander! |
@aliko-str would this be the right example?
|
I'm not sure you've attached the code that you meant... I think I'd do smth like the code below, though it could probably be improved (MDN shouldn't show imperfection..): sizeHasBeenRead seems unnecessary (I don't think it has a practically smaller overhead than re-reading payloadSize; if anything, repeating Buffer.concat every time is worse), flushing and then putting data back in 'chunks' feels wrong, recursion (processData from processData) usually means I was too lazy to do things properly, 'chunks' can be a const, 'payloadSize' can be kept inside processData if it's re-read, flushChunksQueue is then unnecessary and can be reduced down to 'chunks.splice(0);', and maybe smth else. #!/usr/local / bin / node (() => {
})(); |
@aliko-str would you like to submit a PR with you changes? |
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:
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
en-us/mozilla/add-ons/webextensions/native_messaging
The text was updated successfully, but these errors were encountered: