Skip to content
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

Message passing: can't pass file handle or other objects that aren't JSON-serializable #430

Closed
NV opened this issue Jul 23, 2023 · 2 comments
Labels
proposal Proposal for a change or new feature

Comments

@NV
Copy link

NV commented Jul 23, 2023

Currently, it isn't possible to pass the file handler object using browser.runtime.sendMessage, yet it works fine with window.postMessage.

I propose to make message-passing object serialization logic work the same as for postMessage.


In my particular case, I want an extension to back up data to a file periodically. Currently, I have to use IndexedDB to pass the file handler to the service worker. (There are more hurdles to overcome before I could write to a file periodically, but those are out of the scope of this proposal.)

@NV NV added proposal Proposal for a change or new feature and removed needs-triage labels Jul 23, 2023
@NV NV changed the title Message passing: can't pass file handler or other objects that aren't JSON-serializable Message passing: can't pass file handle or other objects that aren't JSON-serializable Jul 23, 2023
@tophf
Copy link

tophf commented Jul 23, 2023

It's already summarized by Rob--W in #293 (comment).

P.S. For chrome-extension:// scripts (i.e. not content scripts) there's a faster workaround: serviceWorker messaging (the example calls register() but you won't need to).

@NV
Copy link
Author

NV commented Jul 24, 2023

Good to know. I'll close it then.

Thanks for the workaround!

@NV NV closed this as completed Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Proposal for a change or new feature
Projects
None yet
Development

No branches or pull requests

2 participants