Chunked messaging flow

Hey guys, I was wondering wondering if chunked messaging was ever considered for @plasmohq/messaging, or if it is part of the roadmap. A few months ago when experimenting with the native chrome.runtime messaging API, I've found that if you're trying to send a large message to the background, it fails to do so. I've solved this in the ArConnect extension by having multiple messages with chunks of the data i'm sending, but I'm wondering if a native support for this, built into the messaging library was more appropriate. The library could automatically decide, if a message needs to be send chunked or not. (Unfortunately I couldn't find any info in the chrome extension docs about the limit for messages).
13 Replies
lab
lab•2y ago
This sounds like a great suggestion @Marton thanks for bringing it up
YAGPDB.xyz
YAGPDB.xyz•2y ago
Gave +1 Rep to @Marton
lab
lab•2y ago
can you file an RFC on the framework repo, also is your chunking implemention source available for study? I did that before for audio signal processing but would love to see what technique you used for this I wonder if we should separate the API or automatically chunk them tho :d
martonlederer
martonledererOP•2y ago
hmm good question @louis will file the RFC asap only thing is that for the chunks to work for sure, the message needs to be an object with some extra infos, such as the index of the chunk, or the qty of the total chunks
lab
lab•2y ago
Yeah we can enforce string/serializable data only And just json stringify then turn it into a buffer
martonlederer
martonledererOP•2y ago
so that we know how to reconstruct the object and know when the chunk stream ended yeah yeah sounds good
lab
lab•2y ago
What's the buffer size are you using to transfer?
martonlederer
martonledererOP•2y ago
wdym exactly? like the limit for the chrome message size?
lab
lab•2y ago
Oh I mean the chunk size 1024/2048 etc..
martonlederer
martonledererOP•2y ago
ah yeah not sure i'll check it
martonlederer
martonledererOP•2y ago
Hey @louis, I finally had time to work on the RFC. I also experimented and found that the max message size is 67108862 bytes, but I'm unsure if this changes on machines with other architecture. Here's the RFC, I'll probably get started on working a PR tomorrow to speed up the process, so you don't have to work on this for us 😄 https://github.com/PlasmoHQ/plasmo/issues/524
GitHub
[RFC] Automatic chunked messaging · Issue #524 · PlasmoHQ/plasmo
How do you envision this feature/change to look/work like? The new system would automatically split the message data into pieces that wouldn't reach the size limitation of the browser messaging...
lab
lab•2y ago
Yo sounds awesome! BTW I meant to respond to this long ago but fell ill past 2 weeks xd
martonlederer
martonledererOP•2y ago
Haha no problem, hope you're feeling better. I am now working on this
Want results from more Discord servers?
Add your server