I got this bug like this:
AbortError: The operation was aborted.
And that is everything I got, no guide or anything that can tell me what part in my code causes this.
However, I still try my best to narrow the scope. Here is the my file, the one causes that bug:
(This file works as background script and handles install event. Something likes what should extension do after the first installation or after updating)
const install = () => {
const defaultSE = 0;
const setSE = (id) => {
const hasPatIn = arr => {
for (let item of arr)
return (item.id == id) ? item.pattern : null
}
fetch('./se.json')
.then(res => res.json())
.then(ls => {// The bug must happen around here...
const searchEngine = {
id: id,
pattern: hasPatIn(ls)
};
browser.storage.sync.set({ searchEngine })
})
}
const hasSE = callback => {
browser.storage.sync.get(
'searchEngine',
se => {
if (
Object.keys(se).length === 0
&& se.constructor == Object
) callback('404')
}
)
}
hasSE(no => setSE(defaultSE))
}
install()
const update = () => {
//
}
function setup(details) {
switch (details.reason) {
case "install":
install();
break;
case "update":
update();
break;
}
}
//browser.runtime.onInstalled.addListener(setup)
What do you guy do in this case? Can I have an advice please?