You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With following code, I can receive the command from firebase properly but chrome.runtime is undefined as I am using it outside of function defineBackground.
But if I move the onSnapshot function into defineBackground function side, snapshot doesn't receive the trigger events anymore.
import{db}from'../firebase'import{collection,query,where,onSnapshot,addDoc,updateDoc,doc}from'firebase/firestore'// Listen for commands from masterconstcommandsQuery=query(collection(db,'commands'),where('status','==','pending'))onSnapshot(commandsQuery,(snapshot)=>{snapshot.docChanges().forEach(async(change)=>{if(change.type==='added'){constcommand=change.doc.data()console.log('Received command from master:',command)// Process commandconstresult=awaitprocessCommand(command)// Send response back to masterconstresponsesRef=collection(db,'responses')awaitaddDoc(responsesRef,{commandId: change.doc.id,
result,timestamp: newDate(),status: 'pending',sender: 'slave'})// Mark command as processedawaitupdateDoc(doc(db,'commands',change.doc.id),{status: 'processed'})}})})asyncfunctionprocessCommand(command: any){// Implement your command processing logic herechrome.runtime.sendMessage({type: 'COMMAND_RECEIVED',payload: command})return`Processed command: ${command.command}`}exportdefaultdefineBackground(()=>{console.log('Hello background!',{id: browser.runtime.id});});
you can reproduce the bugs using this repo
They have 2 folder master and slave, the goal is to send message from one extension to others using firebase event triggering.
At first you can use current code and test to send message from master to slave, then it will get the message in firebase but not able to send message to the pop up using chrome.runtime.
Looking forward to hearing from you soon. @aklinker1 or All Devs
skwsccss
changed the title
[Urgent] Firebase event trigger integration with WXT
[Urgent] Help to figure out Firebase event trigger integration with WXT
Feb 21, 2025
aklinker1
changed the title
[Urgent] Help to figure out Firebase event trigger integration with WXT
Help to figure out Firebase event trigger integration with WXT
Feb 21, 2025
@aklinker1 Thank you for your response.
Yes, the issue is causing when I move all functions go inside defineBackground function.
The onSnapshot function can't receive inside the defineBackground.
And I tried with browser.runtime, in this case I am getting Failed to send message: Error: No listeners available.
Can you please reproduce the issues pulling my repository? it's simple, no complex logic.
Looking forward to getting help from you soon.
Thank again
Describe the bug
With following code, I can receive the command from firebase properly but chrome.runtime is undefined as I am using it outside of function defineBackground.
But if I move the onSnapshot function into defineBackground function side, snapshot doesn't receive the trigger events anymore.
Reproduction
https://github.com/skwsccss/wxt-issue-with-firebase
you can reproduce the bugs using this repo
They have 2 folder master and slave, the goal is to send message from one extension to others using firebase event triggering.
At first you can use current code and test to send message from master to slave, then it will get the message in firebase but not able to send message to the pop up using chrome.runtime.
Looking forward to hearing from you soon. @aklinker1 or All Devs
Steps to reproduce
No response
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: