Skip to content

Should we run interceptor handler for destroyed(/aborted) requests? #444

@mikicho

Description

@mikicho

In Nock, we have this test:

  it.only('Emits the expected event sequence when `end` is called on an aborted request', done => {
    const scope = nock('http://example.test').get('/').reply()

    const req = http.request('http://example.test')
    const emitSpy = sinon.spy(req, 'emit')
    req.abort()
    req.end()

    setTimeout(() => {
      expect(emitSpy).to.have.been.calledTwice
      expect(emitSpy.firstCall).to.have.been.calledWith('close')
      expect(emitSpy.secondCall).to.have.been.calledWith('abort')
      expect(scope.isDone()).to.be.false()
      done()
    }, 10)
  })

This test fails on this line:

expect(scope.isDone()).to.be.false()

because we handle the end event as usual even for aborted requests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions