re: "Extension service workers usually do more heavy tasks than standard Web service workers..."
Indeed they do.
Somehow there seems to be a perception that stateless behavior environment is the only thing that extensions (or background pages) do or can live within.As many comments, questions and oh-my-gosh-wtf-do-I-do-now conversations here should have alluded to by now, this is far from the case. Something should seem wrong with the abstract model if there are a lot of round pegs not fitting into square holes.
Stateless service workers are not the Unified Field Theory / Theory of Everything. Be that as may ---
There seems to be a discussion about potential 'abuse' of stateful behavior . The use of the word 'abuse' is qualitative and incredibly subject to opinion and religiousity. (sorry, Bill Maher), and as legal minds would say 'potential' assumes facts not in evidence [unless we are inside a Minority Report].
So let's focus on the fact that there are both stateful and stateless extensions and that they are both valid - neither one is ''abusive'. As many discussions have tried so hard to illuminate, stateful behaviors are used to SAVE resources (cpu time, memory, and perceived responsiveness) in addition to functionality. I ask is that not the point of this whole exercise??? [Just wondering.]
re: "background scripts should not be stopped until they have complete their tasks"
How can anyone pre-suppose what 'completing their tasks' means? Simply because an execution thread is 'idle' does not mean that it has 'completed its task'. ***
It could be waiting for user interaction with various foreground parts of the extension to then communicate with a tabs content scripts or vice versa. There are no time-limits on human interaction nor on the tab's behavior that would then trigger such a communication - that then depends upon a stateful environment to serve the needs of the user. Why? because if the stateful condition disappears we have only frustrated the user in one way or another - [not just caused a complete redesign and re-coding of the extension, [sarc-on] but then we know we all have limitless resources to do this [sarc-off] This is either because it is just plain impossible to recover state and connections implying that state OR recovering browser execution context AND application state consumes so many resources in the first place (so much more than just maintaining stateful-ness).
Why is it so unacceptable to be stateful when it truly addresses the needs of the 'application' and of the consumer?
Is there not some other way of dealing with this instead of creating a convoluted 'pretzel' to shoe-horn something in a model-of-everything that does not fit the model-of-everything?
If there is still the perception of stateful 'abuse', then, at the very least, allow any extension to be granted stateful permission if nothing else can be imagined!
Thanks, respectfully,
Chrys
*** If for some reason the reader does not perceive this as a problem, imagine how, not-in-an-extension-environment, bloody frustrating it is to have been working on a web-based application only to be called into an extended zoom meeting - then coming back and finding, upon swtiching back to that TAB, that the application's TAB state has been wiped and the url is reloaded being from square 0 . [This is ACTUAL behavior :: bug in v109 trying to make tab behavior be like a service worker.] Would you not be screaming? [Analogy] - Now imagine if that little girl were ... [from Matthew M's (Jake Brigance's) summation to the jury in A Time to Kill.]
2B | !(2B) E ? }-> : 0
[It is getting to tiring dealing with the 'slings arrows of outrageous fortune'....]