【问题标题】:Firefox Push API - AbortError: Error retrieving push subscriptionFirefox Push API - AbortError:检索推送订阅时出错
【发布时间】:2026-01-10 06:35:01
【问题描述】:

我使用的是 46.0a1 版本的 Firefox Nightly(OS X 只有 42v,而 Push API 需要 43v)。

我收到了这个错误:

DOMException [AbortError: "Error retrieving push subscription"
code: 20
nsresult: 0x80530014]

这里是抛出这个错误的sn-p:

navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {

    serviceWorkerRegistration.pushManager.subscribe()
        .then(function (subscription) {
            endpoint = subscription.endpoint;
            console.log('subscription endpoint: ', subscription.endpoint);
            subscribeOnServer();
        })
        .catch(function (e) {

            // here that error is raised

            errorNotification.innerHTML = 'Unable to subscribe to push';
        }
    });
});

在 Chrome 中,这个地方不会抛出任何东西,我通过正确的端点获得订阅。

【问题讨论】:

  • 我遇到了类似的错误。在about:config 中启用所有标志dom.push.* 有帮助。
  • dom.push.adaptive.enabled 对我有用
  • 我也遇到了这个问题,但是因为默认的 serviceworker 和 push 在 Firefox 上没有启用,所以我更新了 about:config 然后出现这条消息 AbortError: Error retrieving push subscription this resolve with me after restarting Firefox ,我认为在重新启动之前不会应用新配置

标签: web-push push-api firefox-nightly


【解决方案1】:

它不适合我。

您的 sn-p 中存在语法错误,但我想这不是问题(否则它也会在 Chrome 中失败)。

这是我用过的sn-p:

navigator.serviceWorker.ready
.then(function(serviceWorkerRegistration) {
  console.log('asd');
  serviceWorkerRegistration.pushManager.subscribe()
  .then(function(subscription) {
    endpoint = subscription.endpoint;
    console.log('subscription endpoint: ', subscription.endpoint);
  })
  .catch(function(e) {
    console.log(e);
  });
});

【讨论】:

    【解决方案2】:

    我最近发现,如果您的浏览器位于不支持 Web 套接字的代理后面(推送服务在内部使用 Web 套接字),则可能会出现此错误。

    【讨论】:

      【解决方案3】:

      当我的服务人员出现错误(试图访问 indexedDb 中不存在的存储)时,我收到了这个错误,所以即使它安装了,但推送通知没有被订阅并出现上述错误。

      【讨论】: