Chrome Extension Service Worker不活动之后“清除站点数据”
我的清单 v3 扩展中有一个非常简单的后台脚本,它基本上等待消息,然后从同步存储中检索一个值,如下所示:
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.storage.sync.get("value", ({ value }) => {
... do some stuff
}
}
现在这工作正常,直到我转到扩展的 DevTools -> 。应用->存储->清除站点数据。
之后,我的服务工作线程始终处于“不活动”状态,并且当我向其发送消息时不会变为活动状态。仅当我转到 chrome://extensions 并禁用/启用扩展时,服务工作线程才会再次开始运行。
最奇怪的是我的 popup.js 实际上仍然可以从同步存储中获取值。清除站点数据后怎么可能?
I have a very simple background script in my manifest v3 extension that basically waits for messages and then retrieves a value from sync storage like so:
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.storage.sync.get("value", ({ value }) => {
... do some stuff
}
}
Now this works fine until i goto the DevTools of my extension -> Application -> Storage -> Clear site data.
After that my service worker is always "inactive" and does not become active when I send messages to it. Only when I go to chrome://extensions and disable/enable the extension the service worker starts functioning again.
The weirdest thing is that my popup.js can actually still get the value from sync storage. How is that possible after I clear the site data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论