清单v3 newtab和背景服务工作者:无法建立连接。接收端不存在

发布于 2025-01-31 02:40:38 字数 394 浏览 2 评论 0原文

我有自己的newtab页面,在加载访问背景服务工作者(进行一些API调用)上

"chrome_url_overrides": {
    "newtab": "newtab/newtab.html"
  },
  "background": {
    "service_worker": "background.js"
  },

,但如果它是在初始浏览器启动中加载的第一个选项卡。 它给出了这个错误 无法建立联系。接收端不存在

可能是因为NEWTAB脚本比服务工作者听众早启动?

runtime.onMessage.addListener

因为第二个NEWTAB没有给出此错误。如何解决这个问题?

I have my own newtab page which on load access background service worker(making some API calls)

"chrome_url_overrides": {
    "newtab": "newtab/newtab.html"
  },
  "background": {
    "service_worker": "background.js"
  },

BUT if it is a first tab loaded on the INITIAL browser launch.
It gives this error
Could not establish connection. Receiving end does not exist

Could it be because newtab script is started earlier than service worker listener?

runtime.onMessage.addListener

Because second newtab is not giving this error. How to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文