mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
535 stars 120 forks source link

Socket: Respect "connect" and "setTimeout" behaviors #455

Closed mikicho closed 1 month ago

mikicho commented 11 months ago

I unified this in one issue because we need to take all of these into account in the solution.

  1. Socket authorized and encrypted are false for https requests

    https.get('https://example.test').on('socket', socket => {
    expect(socket.authorized).to.equal(true) // always false, test fails
    expect(socket.encrypted).to.equal(true) // always false, test fails
    done()
    })
  2. never emit (socket) connect event for an invalid URL (e.g. example.test) because Node tries to connect to the URL, and we capture the ENOTFOUND.

  3. We can't use socket.setTimeout for invalid URL (e.g. example.test`) because it emits error