-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Messaging from background to popup stuck #37
Comments
Messages get queued for the destination if it is not immediately available. What behavior were you expecting? |
My case is maybe somehow not usual, but it is to send updates to the Popup window. Would have liked to find a way to send messages to my Popup tab only if it is actually ready to received (Active or Able to execute what it receives) I tried to make a subscribe system for tabs who wanna received those messages, but can't find a solution to unsubscribe from the Popup whenever it unloads. |
I see. Have you tried fixing this by having the senders wait for the "wake" signal from popup before they send any messages? Also use |
Using But I am now having three problems (one I had before and now)
|
Can you please share a minimal repro for the errors you are getting that I can test against? |
For my background job, I would have: onMessage('setting-update', async ({ data }) => {
await database.settings.updateSetting(data)
})
onMessage('settings-fetch', async ({ sender, data }) => {
console.log('test', sender, data)
await sendMessage('settings-fetch-response', await database.settings.getSettings(), { ...sender, tabId: data.tabId })
}) and for the popup: onMessage('settings-fetch-response', ({ data }) => {
settingsStore.loadSettings(data)
})
browser.tabs.query({ currentWindow: true, active: true })
.then((data) => {
tabId.value = data[0]?.id
if (tabId.value) {
sendMessage('settings-fetch', { tabId: tabId.value }, 'background')
}
}) PS: it works, just sends errors in console |
onMessage('settings-fetch', async ({ sender, data }) => {
console.log('test', sender, data)
await sendMessage('settings-fetch-response', await database.settings.getSettings(), { ...sender, tabId: data.tabId })
}) You don't have to use |
I'm having this same issue. I can get the message to popup from background but I have to use the
returning the value does not work. |
Can you please install |
I get the same issue, with both Checking the parameter of |
I don't have too much experience with popups and the challenges that come with them. I'm also unable to allocate resources to this task, can someone please take on this problem? |
@zikaari Can you point in the code where the wrapping from the underlaying runtime.onMessage to Sender type happens? |
I was having a similar issue where I was having problems with returning the values. On carefully reading the documentation, I figured it out. You have to return the onMessage("settings-fetch", async ({ sender, data }) => {
return database.settings.getSettings(); // returning the promise, not the awaited value
}; |
Whenever my popup is closed, and I use sendMessage it is stuck and waiting for the popup to open
I can't find any fix on my side to check if the tab is contactable or not, any solution ? Is it a bug ?
The text was updated successfully, but these errors were encountered: