-
-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should we run interceptor handler for destroyed(/aborted) requests? #444
Comments
Also, we have this test: it.only('Emits the expected event sequence when aborted immediately after `end`', done => {
const scope = nock('http://example.test').get('/').reply()
const req = http.request('http://example.test')
const emitSpy = sinon.spy(req, 'emit')
req.end()
req.abort()
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)
}) Which first ends the request and then aborts it. |
@mikicho, this is what would happen if you end the request and then abort it:
I believe this makes sense intention wise—aborted requests cannot have responses. We've recently improved this behavior in #394, and I believe What does Nock expect in this case? |
Nock tests two scenarios (attached above)
In both cases, Nock (or node RequestClient) emits an
I believe the issue is that we execute the interceptor logic normally when |
Since those two scenarios are a bit different, we will handle them differently.
|
Nock has an extensive testing suite around the
From what I see, Node doesn't throw, instead, it emits
From Nock POV. Yes, except it shouldn't arrive at the |
I think we can close this one. |
In Nock, we have this test:
This test fails on this line:
because we handle the
end
event as usual even for aborted requests.The text was updated successfully, but these errors were encountered: