问题
Can't see logs of my service worker. Here are steps I tried to open logs for registered and running service worker.
- Open
chrome://serviceworker-internals/
- Click Start and Inspect
- Refresh inspect window
- 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