I don't think your interpretation of the specification is accurate. There are two relevant areas of the specification that come into play: the definition of a service worker's lifetime and the way ExtentableEvent interacts with that lifetime.
Regarding the definition of a service worker lifetime, the
Lifetime section of the spec currently states:
- Has no event to handle.
- Detects abnormal operation: such as infinite loops and tasks exceeding imposed time limits (if any) while handling the events.
Rephrasing this slightly, a UA may terminate a service worker if it does not behave as desired. The only description of "abnormal operation" that the spec provides are the examples that immediately follow: "such as infinite loops and tasks exceeding imposed time limits". Given the non-specific, open-ended nature of this language, I would argue that the specification allows individual UAs to define for themselves what they consider "abnormal operation." Even if we read the description of abnormal operation literally only permitting the UA to terminate for "infinite loops" and "tasks exceeding imposed time limits", the definition, implementation, and enforcement of these time limits are not specified. This implicitly leaves it to UAs to decide how they define and enforce "abnormal operation."
At first this text may seem to prohibit UAs from terminating a service worker so long as any extendable event is active (has promises that haven't timed out or been handled), but that interpretation depends on an inaccurate reading of the term "should not". The
Document conventions section states that terms like "must", "may", and "should not" "are to be interpreted as described in RFC 2119."
This RFC contains the following definition for "should not."
4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that
there may exist valid reasons in particular circumstances when the
particular behavior is acceptable or even useful, but the full
implications should be understood and the case carefully weighed
before implementing any behavior described with this label.
In other words, the specification recommends against terminating a service worker when it has pending events, but allows that UAs may do so in some circumstances. Ultimately termination of a service worker may occur at the discretion of a UA.
Chrome's current intent is that an extension's service worker will be terminated after five minutes (plus a small window). The only exception to this is that native messaging ports opened by the service worker should extend the service worker's lifetime for the duration of the native messaging port (plus a small window). Anything else that extends an extension service worker's lifetime is not behaving as expected and is subject to change.