Skip to content

Consider network.pause() in NetworkApi #2723

Description

@kettanaito

Scope

Improves an existing behavior

Compatibility

  • This is a breaking change

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions