Can't see service worker logs

守給你的承諾、 提交于 2019-12-23 03:25:23

问题


Can't see logs of my service worker. Here are steps I tried to open logs for registered and running service worker.

  1. Open chrome://serviceworker-internals/
  2. Click Start and Inspect
  3. Refresh inspect window
  4. Wait for logs to appear

But, both chrome://serviceworker-internals/ and ServiceWorker inspection shows zero logs.

However, source tab on inspect page shows latest code, which should print console.log Here is the source code I am trying to see the logs of

messaging.setBackgroundMessageHandler(payload => {
    const title = payload.notification.title;
    console.log(payload.notification);
    const options = {
        body: payload.notification.body,
        icon: payload.notification.icon,
        click_action: payload.notification.click_action || payload.data.click_action,
        link: payload.notification.link || payload.data.link,
        data: {
            time: new Date(Date.now()).toString(),
        },
    };

    return self.registration.showNotification(title, options);
});


self.addEventListener("notificationclick", function(event) {
    const notification = event.notification;
    notification.close();
    console.log(notification);
    const promiseChain = clients.openWindow('https://helloworld.com');
    event.waitUntil(promiseChain);

});

I am using Chrome v68.0.3440.106, MacOS v10.13.6

来源:https://stackoverflow.com/questions/51821735/cant-see-service-worker-logs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!