0

I have a piece of code (in Dart) to make a periodic timer to run a code to simply print something to the logs. If I stop the worker from dev tools, it stops. If I start it again, nothing is printed in the logs. Where does the code stops? How to properly restart it shall it gets stopped by the browser automatically or via dev tools? Also what is going to happen to it if the worker is restarted from system restarts? Or maybe I should not care about where the code stops or restarts as this is not the correct service worker mindset? I'm just wondering if I should or should not be doing long running tasks in a service worker, like polling, making a persistent connections like WebSocket, and so on.

Thank you

gregory112
  • 324
  • 2
  • 12
  • What logs are you talking about? Service Workers may not log to the console of the website that creates them, maybe this helps: https://stackoverflow.com/questions/39143034/what-is-service-worker-console-where-is-it-in-chrome-browser – DustInComp Aug 31 '23 at 13:26
  • You may also be looking for this: https://developer.mozilla.org/en-US/docs/Web/API/Background_Synchronization_API – DustInComp Aug 31 '23 at 13:46
  • I don't know but in my implementation it does. My service worker is loaded as `sw.dart.js` file. I do `print('Test')` in my Dart code as Service Worker and the log shows up in my log, from `sw.dart.js` file. – gregory112 Sep 01 '23 at 07:53

0 Answers0