mswjs / interceptors

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

error listener get called twice on mocked error with sync handler #492

Closed mikicho closed 8 months ago

mikicho commented 8 months ago

If we remove the await from this test. the Error: socket hang up error get called.

  request.on('error', (error: ConnectionError) => {
    // this log two errors: "ConnectionRefusedError: connect ECONNREFUSED ::1 4444" and then "Error: socket hang up"
    console.log(error);

    errorPromise.resolve(error)
  })

image

as a workaround, I added setTimeout(.., 5).

mikicho commented 8 months ago

Why do we call this.terminate on mocked error?

mikicho commented 8 months ago

duplicate #474