Closed Bug 1212743 Opened 9 years ago Closed 9 years ago

sendMessage requires synchronous response

Categories

(WebExtensions :: Untriaged, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: daleharvey, Unassigned)

References

Details

I have an addon that calls chrome.runtime.sendMessage(json, function (response) { console.log(response); }); It is handled basically like: chrome.runtime.onMessage.addListener(function (req, sender, respond) { var response = localSorage['things']; respond(response); }); However if I try to switch to chrome.storage (that has an async api, or even if I just chrome.runtime.onMessage.addListener(function (req, sender, respond) { var response = localSorage['things']; setTimeout(function() { respond(response) }); }); Then the called never gets the response
Blocks: 877648
Fabrice if you know who would be good to get this in front of it would be useful, cheers, ill stop bothering you shortly when I have more of an idea who else is working on the addon stuff
Flags: needinfo?(fabrice)
Please read the docs for onMessage. https://developer.chrome.com/extensions/runtime#event-onMessage You need to |return true| from it if you want to respond asynchronously.
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: needinfo?(fabrice)
Resolution: --- → INVALID
Awesome thanks, apologies for missing that
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.