Scope
Improves an existing behavior
Compatibility
Feature description
Proposed changes
Add a .pause() method on the NetworkApi and transitively inherit it on setupWorker/setupServer APIs.
Motivation
The semantics of worker.stop() is confusing. Nothing gets stopped or unregistered. The interception gets paused and then implicitly resumed via another worker.start(). I find that utterly confusing.
Instead, the network API should encapsulate:
.pause() to pause the interception. Performs in-flight requests as per handlers;
.resume() to resume the interception. Passes through the in-flight requests.
Specific methods like start/stop become truly reciprocal and worker.stop() then:
- Returns a promise so it can be awaited;
- Unregisters the worker and awaits the confirmation of that;
- Cleans up internal side effects.
Scope
Improves an existing behavior
Compatibility
Feature description
Proposed changes
Add a
.pause()method on theNetworkApiand transitively inherit it onsetupWorker/setupServerAPIs.Motivation
The semantics of
worker.stop()is confusing. Nothing gets stopped or unregistered. The interception gets paused and then implicitly resumed via anotherworker.start(). I find that utterly confusing.Instead, the network API should encapsulate:
.pause()to pause the interception. Performs in-flight requests as per handlers;.resume()to resume the interception. Passes through the in-flight requests.Specific methods like
start/stopbecome truly reciprocal andworker.stop()then: