Skip to content

Support raw net.connection #707

@kettanaito

Description

@kettanaito

Since https://github.com/mswjs/interceptors/releases/tag/v0.32.0, we now technically can implement a net.Socket interceptor that would allow us to intercept ClientRequest but also any agents using sockets directly, like Undici.

This task would involve:

  • Implementing the net.Socket interceptor interface.
  • Refactoring ClientRequest (and potentially XHR) interceptors to rely on the Socket interceptor. These higher level interceptors would only concern themselves with parsing the socket packets and deciding whether a particular connection should be intercepted, then controlling it.
  • Design some sort of manager that would "lock" socket instances behind certain interceptors. This is to avoid issues when a single request can be handled by multiple interceptors (see Deprecate "X-Request-Id" in favor of another request deduplication algorithm #378). Once we bring the interception to the socket level, all requests will be covered by that interceptor and subsequent higher interceptors that extend it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions