Replies: 2 comments 6 replies
-
two write reactive data: /**
if (previousTabId) {
objectDemo.value[previousTabId].status = 'inactive'
objectDemo.value[previousTabId].updatedAt = new Date().toISOString()
}
**/
{
"1982090497":{"name":"page1","status":"inactive","updatedAt":"2024-06-25T14:40:36.452Z"}
}
// await browser.tabs.get(tabId)
/**
objectDemo.value[tabId] = {
name: tab.title,
status: 'active',
updatedAt: new Date().toISOString(),
}
**/
{
"1982090494":{"name":"page2","status":"active","updatedAt":"2024-06-25T14:40:36.452Z"},
"1982090497":{"name":"page1","status":"inactive","updatedAt":"2024-06-25T14:40:36.452Z"}
}Recursive guessing is because: Try fixing it: watchWithFilter(
data,
async () => {
console.log('data changes', data.value)
try {
if (data.value == null) {
storageInterface.removeItem(key)
return
}
const currentStorageValue = await storageInterface.getItem(key)
const setStorageValue = await serializer.write(data.value)
if (setStorageValue !== currentStorageValue)
storageInterface.setItem(key, setStorageValue)
}
catch (error) {
onError(error)
}
},
{
flush,
deep,
eventFilter,
},
)sorry, Poor English, not very clear expression 😂 |
Beta Was this translation helpful? Give feedback.
6 replies
-
|
Success! Thanks @gxr404 ! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure what is the perpetrator here. I kept running into this recursive error that happened when I was using
useWebExtensionStorage. I finally "fixed" it in my app by adding the debounceFilter when usinguseWebExtensionStorage. I wasn't satisfied, so I fired up fresh vitesse-webext project to see if I could re-produce and investigate from there. Finally, I got it down to the bare minimum to reproduce the bug.To reproduce:
Add to
~/logic/storageAdd these listeners in
~/src/background/main.tsAnd in
useWebExtensionStorage.ts, add aconsole.log('storage changes', changes)to your storage listener function and aconsole.log('data changes', data.value)to yourwatchWithFilterfunction.Now load the extension, open up your service worker console, and navigate between any two tabs. It happens after 3 total tab navigations that I begin seeing an infinite loop of
console.logstatements. Be ready to quickly turn off the extension or else it's going to start eating up your CPU.And I've found a very bizarre fix for this. If someone could explain it to me, because it's beyond me at this point. In the
browser.tabs.onActivatedlistener, if I move the instantiation of tab,const tab = await browser.tabs.get(tabId)to the beginning of function instead of in theelseblock, no infinite loop.So weird!!! Even though the bug goes away, I don't consider it a fix at all.
I set up the repo here if anyone wants to pull and explore
Beta Was this translation helpful? Give feedback.
All reactions